清除密码
This commit is contained in:
1 parent
366b8a4272
commit
dd0005b7ba
2 files changed
+16
-2
No files matched your search
+13
-2
@@ -7,7 +7,15 @@ interface AdminUser {
|
||||
password_reset: number
|
||||
}
|
||||
|
||||
const { isChecking, isAuthenticated, isAdmin, checkSession, fetchStatus, handleAuthError } = useAuth()
|
||||
const {
|
||||
isChecking,
|
||||
isAuthenticated,
|
||||
isAdmin,
|
||||
checkSession,
|
||||
fetchStatus,
|
||||
handleAuthError,
|
||||
getFetchErrorMessage
|
||||
} = useAuth()
|
||||
const toast = useToast()
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -42,7 +50,10 @@ async function clearPassword(user: AdminUser) {
|
||||
await loadUsers()
|
||||
} catch (error: unknown) {
|
||||
handleAuthError(error)
|
||||
toast.add({ title: t('users.clearFailed'), color: 'error' })
|
||||
toast.add({
|
||||
title: getFetchErrorMessage(error, t('users.clearFailed')),
|
||||
color: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ export default defineEventHandler(async (event) => {
|
||||
if (!target) {
|
||||
createApiError(event, 'INVALID_REQUEST', '用户不存在', 404)
|
||||
}
|
||||
if (target.role === 'admin') {
|
||||
createApiError(event, 'FORBIDDEN', '不允许清除管理员账号', 403)
|
||||
}
|
||||
if (target.id === operator.id) {
|
||||
createApiError(event, 'INVALID_REQUEST', '不能清除自己的密码', 400)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user