管理员列表支持解除电子签署身份,处理同一实名绑定冲突
e签宝 对同一证件只签发一个签署账号,同一实名在另一后台账号认证时会绑定冲突。 - 新增 auth.admin/esignUnbind:清除目标账号在当前 e签宝 应用下的签署账号绑定、 在途认证与快捷签授权;有在途操作时拒绝;不注销 e签宝 账号,已签处方不受影响 - 该接口加入 AuthMiddleware 强制鉴权列表,菜单未登记时也不放行; 迁移 2026_11_27_admin_esign_unbind_menu.sql 登记按钮权限,默认仅超级管理员可用 - 管理员列表显示「签署身份」并提供「解除签署」按钮 - 绑定冲突提示指明占用的后台账号(名称 + ID) - 医师认证失败日志把字段写进消息正文(ThinkPHP 不落盘 context) Co-Authored-By: Claude Opus 5 (1M context) <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5 (1M context)
parent
e4d788ed32
commit
2019f9dca1
@@ -137,7 +137,7 @@ namespace {
|
||||
Db::execute($sql);
|
||||
}
|
||||
Db::execute('CREATE TABLE zyt_config (id INTEGER PRIMARY KEY,type TEXT,name TEXT,value TEXT,create_time INTEGER,update_time INTEGER)');
|
||||
Db::execute('CREATE TABLE zyt_admin (id INTEGER PRIMARY KEY,name TEXT,disable INTEGER DEFAULT 0,delete_time INTEGER,root INTEGER DEFAULT 0)');
|
||||
Db::execute('CREATE TABLE zyt_admin (id INTEGER PRIMARY KEY,name TEXT,account TEXT,disable INTEGER DEFAULT 0,delete_time INTEGER,root INTEGER DEFAULT 0)');
|
||||
Db::execute('CREATE TABLE zyt_admin_role (admin_id INTEGER,role_id INTEGER)');
|
||||
Db::execute('CREATE TABLE zyt_doctor_esign_account (doctor_id INTEGER,environment TEXT,app_id TEXT,account_id TEXT,
|
||||
doctor_name TEXT,create_time INTEGER,UNIQUE(doctor_id,environment,app_id))');
|
||||
@@ -345,7 +345,7 @@ namespace {
|
||||
$assert(Enrollment::complete(1)['quicksign_expires_at'] === $now + 120, 'provider validity is preserved when shorter than the local bound');
|
||||
|
||||
$config->set(['review_enabled' => true], 'esign');
|
||||
Db::name('admin')->insert(['id' => 4, 'name' => 'admin', 'root' => 1]);
|
||||
Db::name('admin')->insert(['id' => 4, 'name' => 'admin', 'account' => 'root-account', 'root' => 1]);
|
||||
Provider::$identity = ['status' => 'INIT'];
|
||||
Provider::$newAccountId = 'reviewer-account';
|
||||
$startsBeforeReview = Provider::$starts;
|
||||
@@ -371,5 +371,47 @@ namespace {
|
||||
'verified legal name is saved only to the reviewer signing account');
|
||||
$throws(static fn () => Enrollment::start(4, $phone, '不同姓名'), DomainException::class,
|
||||
'a verified signing account cannot be renamed through enrollment');
|
||||
|
||||
// 同一实名在另一个后台账号认证:e签宝 返回同一签署账号,需管理员解除旧绑定后才能改绑。
|
||||
Db::name('admin')->insert(['id' => 5, 'name' => 'admin2', 'account' => 'second-root', 'root' => 1]);
|
||||
Provider::$identity = ['status' => 'INIT'];
|
||||
Enrollment::start(5, $phone, Provider::NAME);
|
||||
Provider::$identity = ['status' => 'SUCCESS', 'indivInfo' => ['name' => Provider::NAME,
|
||||
'certType' => 'INDIVIDUAL_CH_IDCARD', 'certNo' => Provider::DOCUMENT]];
|
||||
$conflict = '';
|
||||
try {
|
||||
Enrollment::complete(5);
|
||||
} catch (DomainException $error) {
|
||||
$conflict = $error->getMessage();
|
||||
}
|
||||
$assert(str_contains($conflict, '「admin(ID 4)」') && !str_contains($conflict, 'root-account')
|
||||
&& !str_contains($conflict, Provider::DOCUMENT)
|
||||
&& Db::name('doctor_esign_account')->where('doctor_id', 5)->count() === 0
|
||||
&& Db::name('doctor_esign_identity')->where('doctor_id', 5)->value('operation_token') === '',
|
||||
'a conflict names the holding back-office account and keeps the verified flow for retry');
|
||||
$assert(Enrollment::signerNames([4, 5, 0]) === [4 => Provider::NAME], 'admin list sees only current-app bindings');
|
||||
|
||||
$lease = ['doctor_id' => 4, 'environment' => 'sandbox', 'app_id' => 'fixture',
|
||||
'operation_token' => str_repeat('a', 32), 'operation_expires_at' => time() + 60];
|
||||
Db::name('doctor_esign_identity')->insert($lease);
|
||||
$throws(static fn () => Enrollment::unbind(4), DomainException::class, 'an in-flight provider operation blocks unbinding');
|
||||
$assert(Db::name('doctor_esign_account')->where('doctor_id', 4)->count() === 1, 'a blocked unbind changes nothing');
|
||||
Db::name('doctor_esign_identity')->where('doctor_id', 4)->update(['operation_expires_at' => time() - 1]);
|
||||
Db::name('doctor_esign_quicksign')->insert(['doctor_id' => 4, 'environment' => 'sandbox', 'app_id' => 'fixture',
|
||||
'account_id' => 'reviewer-account', 'flow_id' => 'old-grant', 'expires_at' => time() + 3600]);
|
||||
$config->set(['app_id' => 'other-app'], 'esign');
|
||||
$throws(static fn () => Enrollment::unbind(4), DomainException::class, 'unbinding is scoped to the current eSign application');
|
||||
$config->set(['app_id' => 'fixture'], 'esign');
|
||||
Enrollment::unbind(4);
|
||||
$assert(Db::name('doctor_esign_account')->where('doctor_id', 4)->count() === 0
|
||||
&& Db::name('doctor_esign_identity')->where('doctor_id', 4)->count() === 0
|
||||
&& Db::name('doctor_esign_quicksign')->where('doctor_id', 4)->count() === 0
|
||||
&& Db::name('doctor_esign_identity')->where('doctor_id', 5)->count() === 1,
|
||||
'unbinding clears only the target binding, its pending flow and quick-sign grant');
|
||||
$throws(static fn () => Enrollment::unbind(4), DomainException::class, 'unbinding an unbound account is reported');
|
||||
$rebound = Enrollment::complete(5);
|
||||
$assert($rebound['status'] === 'ready'
|
||||
&& Db::name('doctor_esign_account')->where('doctor_id', 5)->value('account_id') === 'reviewer-account',
|
||||
'after unbinding, the verified flow binds the same provider account to the new back-office account');
|
||||
echo "Doctor eSign enrollment: $checks checks passed (SQLite and provider doubles)\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user