fix(otp): 修正 OTP 关闭逻辑

This commit is contained in:
PKC278
2026-01-20 19:54:27 +08:00
parent c1d759f3f3
commit 63d6290166
+5 -1
View File
@@ -5,6 +5,7 @@ import { useDisplay } from 'vuetify'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import api from '@/api' import api from '@/api'
import type { ApiResponse, PassKey } from '@/api/types' import type { ApiResponse, PassKey } from '@/api/types'
import { useGlobalSettingsStore } from '@/stores'
interface Props { interface Props {
modelValue: boolean modelValue: boolean
@@ -21,6 +22,7 @@ const emit = defineEmits(['update:modelValue', 'update:isOtp', 'verifyPassword']
const { t } = useI18n() const { t } = useI18n()
const display = useDisplay() const display = useDisplay()
const $toast = useToast() const $toast = useToast()
const globalSettingsStore = useGlobalSettingsStore()
// 内部状态 // 内部状态
const show = computed({ const show = computed({
@@ -37,6 +39,8 @@ const secret = ref('')
// 确认双重验证密码 // 确认双重验证密码
const otpPassword = ref('') const otpPassword = ref('')
const allowPasskeyWithoutOtp = computed(() => globalSettingsStore.get('PASSKEY_ALLOW_REGISTER_WITHOUT_OTP') === true)
// 二维码图片 base64 // 二维码图片 base64
const qrCodeImage = ref('') const qrCodeImage = ref('')
@@ -104,7 +108,7 @@ async function judgeOtpPassword() {
// 关闭当前用户的双重验证 // 关闭当前用户的双重验证
function disableOtp() { function disableOtp() {
// 如果已绑定PassKey,不允许关闭OTP // 如果已绑定PassKey,不允许关闭OTP
if (props.passkeyList && props.passkeyList.length > 0) { if (props.passkeyList && props.passkeyList.length > 0 && !allowPasskeyWithoutOtp.value) {
$toast.error(t('profile.disableOtpWithPasskeyError')) $toast.error(t('profile.disableOtpWithPasskeyError'))
return return
} }