feat: 添加 Laravel Sanctum 支持,增强管理员 API 鉴权,更新相关中间件与路由配置

This commit is contained in:
2026-05-09 11:11:46 +08:00
parent e478597d13
commit 8a70c029f6
20 changed files with 717 additions and 14 deletions

View File

@@ -7,7 +7,7 @@ use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
/**
* 后台角色super_admin、若干权限占位本地演示**admin@admin.com** / **123456**(仅限非 production
* 后台角色super_admin、若干权限占位本地演示账号 **admin** / **123456**(仅限非 production
*/
class AdminRbacAndUserSeeder extends Seeder
{
@@ -50,11 +50,12 @@ class AdminRbacAndUserSeeder extends Seeder
);
}
$email = 'admin@admin.com';
$username = 'admin';
AdminUser::query()->updateOrCreate(
['email' => $email],
['username' => $username],
[
'name' => 'admin',
'name' => '超级管理员',
'email' => null,
/** 明文;模型 casts `password => hashed`,勿在生产库使用种子弱口令 */
'password' => '123456',
'status' => 0,
@@ -62,7 +63,7 @@ class AdminRbacAndUserSeeder extends Seeder
);
/** @var int $uid */
$uid = (int) AdminUser::query()->where('email', $email)->value('id');
$uid = (int) AdminUser::query()->where('username', $username)->value('id');
DB::table('admin_user_roles')->updateOrInsert(
['admin_user_id' => $uid, 'role_id' => $rid],
[],