feat(passkey): 添加环境变量配置项,允许注册passkey时跳过验证是否已注册otp

This commit is contained in:
PKC278
2026-01-20 00:34:33 +08:00
parent a48fcb3819
commit bea752879c
+6 -1
View File
@@ -6,6 +6,7 @@ import { useI18n } from 'vue-i18n'
import { formatDateDifference } from '@core/utils/formatters' import { formatDateDifference } from '@core/utils/formatters'
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
@@ -26,6 +27,7 @@ const emit = defineEmits(['update:modelValue', 'update:passkeyList', 'verifyPass
const { t, locale } = useI18n() const { t, locale } = useI18n()
const display = useDisplay() const display = useDisplay()
const $toast = useToast() const $toast = useToast()
const globalSettingsStore = useGlobalSettingsStore()
// 内部状态 // 内部状态
const show = computed({ const show = computed({
@@ -45,6 +47,9 @@ const passkeyName = ref('')
// PassKey challenge // PassKey challenge
const passkeyChallenge = ref('') const passkeyChallenge = ref('')
const allowPasskeyWithoutOtp = computed(() => !!globalSettingsStore.get('PASSKEY_ALLOW_REGISTER_WITHOUT_OTP'))
const canRegisterPasskey = computed(() => props.isOtp || allowPasskeyWithoutOtp.value)
// 格式化日期 // 格式化日期
function formatDate(dateStr: string) { function formatDate(dateStr: string) {
return new Date(dateStr).toLocaleDateString(locale.value) return new Date(dateStr).toLocaleDateString(locale.value)
@@ -230,7 +235,7 @@ watch(
</VAlert> </VAlert>
<!-- 注册新通行密钥 --> <!-- 注册新通行密钥 -->
<VCard v-if="props.isOtp" variant="tonal" class="mb-6"> <VCard v-if="canRegisterPasskey" variant="tonal" class="mb-6">
<VCardText> <VCardText>
<h5 class="text-h5 font-weight-medium mb-2">{{ t('profile.registerNewPasskey') }}</h5> <h5 class="text-h5 font-weight-medium mb-2">{{ t('profile.registerNewPasskey') }}</h5>
<p class="mb-4">{{ t('profile.passkeyDescription') }}</p> <p class="mb-4">{{ t('profile.passkeyDescription') }}</p>