diff --git a/packages/ui/certd-client/src/views/framework/login/index.vue b/packages/ui/certd-client/src/views/framework/login/index.vue index 96771bd05..704901ebc 100644 --- a/packages/ui/certd-client/src/views/framework/login/index.vue +++ b/packages/ui/certd-client/src/views/framework/login/index.vue @@ -46,21 +46,11 @@ - - - - + -
@@ -81,7 +71,7 @@ -
+
@@ -195,70 +185,6 @@ const twoFactor = reactive({ verifyCode: "", }); -const passkeySupported = ref(false); -const passkeyEnabled = ref(false); - -const checkPasskeySupport = () => { - passkeySupported.value = false; - if (typeof window !== "undefined" && "credentials" in navigator && "PublicKeyCredential" in window) { - passkeySupported.value = true; - } -}; - -const handlePasskeyLogin = async () => { - if (!passkeySupported.value) { - notification.error({ message: t("authentication.passkeyNotSupported") }); - return; - } - - loading.value = true; - try { - const optionsResponse: any = await request({ - url: "/passkey/generateAuthentication", - method: "post", - }); - const options = optionsResponse; - - console.log("passkey authentication options:", options, JSON.stringify(options)); - const credential = await (navigator.credentials as any).get({ - publicKey: { - challenge: Uint8Array.from(atob(options.challenge.replace(/-/g, "+").replace(/_/g, "/")), c => c.charCodeAt(0)), - rpId: options.rpId, - allowCredentials: options.allowCredentials || [], - timeout: options.timeout || 60000, - // attestation: options.attestation, - // excludeCredentials: excludeCredentials, - // extensions: options.extensions, - // authenticatorSelection: options.authenticatorSelection, - // hints: options.hints, - // 关键配置在这里 👇 - authenticatorSelection: { - residentKey: "required", // 或 "preferred",请求创建可发现凭证 - requireResidentKey: true, // 为兼容旧浏览器,设置与 residentKey 相同的值 - userVerification: "preferred", // 用户验证策略 - }, - }, - }); - - console.log("passkey authentication credential:", credential, JSON.stringify(credential)); - if (!credential) { - throw new Error("Passkey认证失败"); - } - - const loginRes: any = await UserApi.loginByPasskey({ - credential, - challenge: options.challenge, - }); - - await userStore.onLoginSuccess(loginRes); - } catch (e: any) { - console.error("Passkey登录失败:", e); - notification.error({ message: e.message || "Passkey登录失败" }); - } finally { - loading.value = false; - } -}; - const handleFinish = async () => { loading.value = true; try { @@ -307,9 +233,7 @@ const isOauthOnly = computed(() => { return sysPublicSettings.oauthOnly && settingStore.isPlus && sysPublicSettings.oauthEnabled; }); -onMounted(() => { - checkPasskeySupport(); -}); +onMounted(() => {});