强化用户安全信息编辑确认
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-08 12:57:27 +08:00
1 parent 998b68079a
commit f32b81f3f3
4 files changed
+66 -16

No files matched your search

@@ -9,6 +9,7 @@ import {ElNotification} from "element-plus";
import {Plus} from "@element-plus/icons-vue";
import {useGlobalStatusStore} from "@/stores/useGlobalStatusStore";
import {confirmRecentAuthentication, isRecentAuthenticationCancelled} from '@/utils/recentAuthentication'
const roleOptions = {
super_admin: { label: '超级管理员', type: 'danger' },
@@ -74,6 +75,8 @@ export function usePage() {
const externalEmailDialogVisible = ref(false)
const securityDialogOpening = ref('')
const editingCurrentUser = computed(() => isSameUser(selectedUser.value, globalStatus.userInfos))
const recoveryCodeWebManaged = computed(() => canManageRecoveryCode(selectedUser.value))
@@ -122,13 +125,35 @@ export function usePage() {
userInfoDialog.value = true
}
const openRecoveryCodeDialog = function () {
const confirmSecurityDialogAccess = async function (dialogName) {
if (securityDialogOpening.value) return false
securityDialogOpening.value = dialogName
try {
await confirmRecentAuthentication()
return true
} catch (error) {
if (!isRecentAuthenticationCancelled(error)) {
ElNotification({
title: lang.fail,
message: error?.message || '身份确认失败',
type: 'error',
})
}
return false
} finally {
securityDialogOpening.value = ''
}
}
const openRecoveryCodeDialog = async function () {
if (!recoveryCodeWebManaged.value) return
if (!await confirmSecurityDialogAccess('recovery-code')) return
recoveryCodeDialogVisible.value = true
}
const openExternalEmailDialog = function () {
const openExternalEmailDialog = async function () {
if (!selectedUser.value?.ID) return
if (!await confirmSecurityDialogAccess('external-email')) return
externalEmailDialogVisible.value = true
}
@@ -200,6 +225,7 @@ export function usePage() {
recoveryCodeWebManaged,
recoveryCodeDialogVisible,
externalEmailDialogVisible,
securityDialogOpening,
openRecoveryCodeDialog,
openExternalEmailDialog,
handleSecurityChanged,
@@ -122,6 +122,7 @@
</div>
<el-button
:disabled="!recoveryCodeWebManaged"
:loading="securityDialogOpening === 'recovery-code'"
@click="openRecoveryCodeDialog"
>
{{ recoveryCodeWebManaged ? '管理安全码' : '仅支持本机管理' }}
@@ -137,7 +138,12 @@
).label }}
</span>
</div>
<el-button @click="openExternalEmailDialog">编辑外部邮箱</el-button>
<el-button
:loading="securityDialogOpening === 'external-email'"
@click="openExternalEmailDialog"
>
编辑外部邮箱
</el-button>
</div>
</div>
@@ -201,6 +207,7 @@ const {
recoveryCodeWebManaged,
recoveryCodeDialogVisible,
externalEmailDialogVisible,
securityDialogOpening,
openRecoveryCodeDialog,
openExternalEmailDialog,
handleSecurityChanged,