feat: refactor super admin to use is_super_admin flag and enhance site deletion logic
- Changed super admin detection from role-based to `is_super_admin` flag in AdminUser model
- Added `requireDefaultAdminSiteId()` method to throw validation error when no integration site exists
- Enhanced site deletion to migrate platform role bindings to fallback site and auto-delete site-specific admin accounts
- Made agent line code optional with auto-generation fallback using `{site_code}-agent-{counter}` format
This commit is contained in:
@@ -21,33 +21,7 @@ test('admin auth me returns current admin profile', function () {
|
||||
'email' => null,
|
||||
'password' => 'secret-strong',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$roleId = DB::table('admin_roles')->insertGetId([
|
||||
'code' => 'super_admin',
|
||||
'slug' => 'super_admin',
|
||||
'name' => '超级管理员',
|
||||
'description' => null,
|
||||
'status' => 1,
|
||||
'is_system' => true,
|
||||
'sort_order' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$siteId = DB::table('admin_sites')->insertGetId([
|
||||
'code' => 'default',
|
||||
'name' => '默认站点',
|
||||
'is_default' => true,
|
||||
'status' => 1,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('admin_user_site_roles')->insert([
|
||||
'admin_user_id' => $admin->id,
|
||||
'site_id' => $siteId,
|
||||
'role_id' => $roleId,
|
||||
'granted_at' => now(),
|
||||
'is_super_admin' => true,
|
||||
]);
|
||||
|
||||
$token = $admin->createToken('admin-api', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
Reference in New Issue
Block a user