From acad7f1a09a90898f72717cf8d3bf6faea35b663 Mon Sep 17 00:00:00 2001 From: shaw Date: Tue, 28 Jul 2026 22:51:58 +0800 Subject: [PATCH] fix(profile): stop passkey load error toast when feature is disabled The PASSKEY_DISABLED silence guard compared the string error code against error.code, but the api client puts the numeric envelope code there and the string code in error.reason, so the guard never matched and every /profile visit on deployments without WebAuthn configured showed a spurious "failed to load passkeys" toast. Read error.reason instead, and skip the credentials request entirely when the feature is disabled so the card no longer issues a request that is guaranteed to fail with 403. --- .../src/components/user/profile/ProfilePasskeyCard.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/user/profile/ProfilePasskeyCard.vue b/frontend/src/components/user/profile/ProfilePasskeyCard.vue index 0b60113d89..e52ffaf4a9 100644 --- a/frontend/src/components/user/profile/ProfilePasskeyCard.vue +++ b/frontend/src/components/user/profile/ProfilePasskeyCard.vue @@ -205,12 +205,18 @@ function extractErrorMessage(error: unknown, fallback: string): string { } async function loadCredentials(): Promise { + if (!props.enabled) { + credentials.value = [] + return + } loading.value = true try { credentials.value = await passkeyAPI.list() } catch (error) { - const code = (error as { code?: string }).code - if (code !== 'PASSKEY_DISABLED') { + // 字符串错误码在 reason 字段(code 是数字状态码); + // 设置变更竞态下后端仍可能返回 PASSKEY_DISABLED,静默处理 + const reason = (error as { reason?: string }).reason + if (reason !== 'PASSKEY_DISABLED') { appStore.showError(t('profile.passkey.loadFailed')) } } finally {