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: 'id', type: 'integer'),
new OA\Property(property: 'username', type: 'string'), new OA\Property(property: 'username', type: 'string'),
new OA\Property(property: 'email', type: 'string'), new OA\Property(property: 'email', type: 'string'),
new OA\Property(property: 'role', type: 'string', example: 'administrator'),
], type: 'object'), ], type: 'object'),
], type: 'object'), ], type: 'object'),
]) ])
@@ -254,6 +255,8 @@ class AuthController extends AbstractController
$user->refresh_token_expires_at = Carbon::now()->addDays(30); $user->refresh_token_expires_at = Carbon::now()->addDays(30);
$user->save(); $user->save();
$user->load('role');
OperationLogService::log( OperationLogService::log(
user_id: $user->id, user_id: $user->id,
action: 'auth.login', action: 'auth.login',
@@ -275,6 +278,7 @@ class AuthController extends AbstractController
'id' => $user->id, 'id' => $user->id,
'username' => $user->username, 'username' => $user->username,
'email' => $user->email, '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: 'role_id', type: 'integer', nullable: true, example: 1),
new OA\Property(property: 'api_key_enabled', type: 'boolean', example: false), 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: '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: '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: 'created_at', type: 'string', format: 'date-time'),
new OA\Property(property: 'updated_at', type: 'string', format: 'date-time'), new OA\Property(property: 'updated_at', type: 'string', format: 'date-time'),
+1 -1
View File
@@ -167,7 +167,7 @@ function handleCancel() {
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="角色" name="role_id"> <a-form-item label="角色" name="role_id">
<a-select v-model:value="formState.role_id" placeholder="请选择角色" allow-clear> <a-select v-model:value="formState.role_id" placeholder="请选择角色">
<a-select-option v-for="role in roles" :key="role.id" :value="role.id"> <a-select-option v-for="role in roles" :key="role.id" :value="role.id">
{{ role.name }} {{ role.name }}
</a-select-option> </a-select-option>