impl fix for user role

This commit is contained in:
2026-03-19 09:13:20 +08:00
parent 770f26afb1
commit e4fd8ca380
3 changed files with 14 additions and 1 deletions
@@ -189,6 +189,7 @@ class AuthController extends AbstractController
new OA\Property(property: 'id', type: 'integer'),
new OA\Property(property: 'username', type: 'string'),
new OA\Property(property: 'email', type: 'string'),
new OA\Property(property: 'role', type: 'string', example: 'administrator'),
], type: 'object'),
], type: 'object'),
])
@@ -254,6 +255,8 @@ class AuthController extends AbstractController
$user->refresh_token_expires_at = Carbon::now()->addDays(30);
$user->save();
$user->load('role');
OperationLogService::log(
user_id: $user->id,
action: 'auth.login',
@@ -275,6 +278,7 @@ class AuthController extends AbstractController
'id' => $user->id,
'username' => $user->username,
'email' => $user->email,
'role' => $user->role?->name ?? 'accessor',
],
],
];
+9
View File
@@ -35,6 +35,15 @@ use Qbhy\HyperfAuth\Authenticatable;
new OA\Property(property: 'role_id', type: 'integer', nullable: true, example: 1),
new OA\Property(property: 'api_key_enabled', type: 'boolean', example: false),
new OA\Property(property: 'ext', type: 'object', nullable: true, example: ['nickname' => 'user']),
new OA\Property(
property: 'role',
type: 'object',
nullable: true,
properties: [
new OA\Property(property: 'id', type: 'integer', example: 1),
new OA\Property(property: 'name', type: 'string', example: 'administrator'),
]
),
new OA\Property(property: 'refresh_token_expires_at', type: 'string', format: 'date-time', nullable: true),
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
new OA\Property(property: 'updated_at', type: 'string', format: 'date-time'),