From e03eb35fd422aa1faadcf298c8016f83fc94d96d Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Thu, 29 Jan 2026 18:55:57 +0800 Subject: [PATCH] feat: add auto passkey trial tracking to login form - Introduced functionality to track if the auto passkey login has been attempted using session storage. - Implemented methods to initialize and mark the auto passkey trial status. - Automatically trigger passkey login if conditions are met during settings retrieval. --- .../src/views/login/components/login-form.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frontend/src/views/login/components/login-form.vue b/frontend/src/views/login/components/login-form.vue index 013bc9b40cea..06a1ba9fe1b8 100644 --- a/frontend/src/views/login/components/login-form.vue +++ b/frontend/src/views/login/components/login-form.vue @@ -268,6 +268,8 @@ const errCaptcha = ref(false); const errMfaInfo = ref(false); const passkeySetting = ref(false); const passkeySupported = ref(false); +const autoPasskeyTried = ref(false); +const autoPasskeyTriedKey = '1panel-passkey-auto-tried'; const showPasswordLogin = ref(false); const isDemo = ref(false); const isIntl = ref(true); @@ -340,6 +342,17 @@ const captcha = reactive({ const loading = ref(false); const mfaShow = ref(false); const dropdownText = ref('中文(简体)'); +const initAutoPasskeyTried = () => { + try { + autoPasskeyTried.value = sessionStorage.getItem(autoPasskeyTriedKey) === '1'; + } catch (error) {} +}; +const markAutoPasskeyTried = () => { + autoPasskeyTried.value = true; + try { + sessionStorage.setItem(autoPasskeyTriedKey, '1'); + } catch (error) {} +}; const languageLabelMap: Record = { zh: '中文(简体)', @@ -602,6 +615,10 @@ const getSetting = async () => { if (res.data.passkeySetting && !isIntl.value && !isFxplay.value) { loginForm.agreeLicense = true; } + if (passkeySetting.value && passkeySupported.value && !autoPasskeyTried.value) { + markAutoPasskeyTried(); + passkeyLogin(); + } } catch (error) {} }; @@ -649,6 +666,7 @@ function adjustColorToRGBA(color: string, percent: number, opacity: number): str onMounted(() => { globalStore.isOnRestart = false; passkeySupported.value = !!window.PublicKeyCredential && window.isSecureContext; + initAutoPasskeyTried(); getSetting(); getXpackSettingForTheme(); if (!globalStore.ignoreCaptcha) {