From dcc4055eca90a3d0fd39dce9b77f14bef5835f42 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 15 May 2026 14:01:18 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20Unterst=C3=BCtzung=20f=C3=BCr=20Pla?= =?UTF-8?q?tform-Authentifikatoren=20hinzu=20und=20passe=20die=20Passkey-R?= =?UTF-8?q?egistrierungsoptionen=20f=C3=BCr=20Firefox=20an.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/mitgliederbereich/profil.vue | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pages/mitgliederbereich/profil.vue b/pages/mitgliederbereich/profil.vue index e1f2061..3c901b5 100644 --- a/pages/mitgliederbereich/profil.vue +++ b/pages/mitgliederbereich/profil.vue @@ -399,6 +399,16 @@ const isFirefoxBrowser = () => { return /firefox/i.test(ua) } +const hasPlatformAuthenticator = async () => { + if (!process.client || !window.PublicKeyCredential) return false + if (typeof window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable !== 'function') return false + try { + return await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() + } catch { + return false + } +} + const addPasskey = async () => { passkeyError.value = '' passkeyLoading.value = true @@ -406,10 +416,12 @@ const addPasskey = async () => { const name = window.prompt('Name für den Passkey (z.B. "iPhone", "Laptop"):', 'Passkey') || 'Passkey' const mod = await import('@simplewebauthn/browser') - // Firefox/Linux kommt mit localDevice teils nicht klar. Für Chromium bevorzugen wir lokal. - const registrationOptionsRequest = isFirefoxBrowser() - ? { method: 'POST' } - : { method: 'POST', body: { preferredAuthenticatorType: 'localDevice' } } + // localDevice nur setzen, wenn das Gerät wirklich einen Platform-Authenticator hat. + const firefox = isFirefoxBrowser() + const platformAvailable = await hasPlatformAuthenticator() + const registrationOptionsRequest = (!firefox && platformAvailable) + ? { method: 'POST', body: { preferredAuthenticatorType: 'localDevice' } } + : { method: 'POST' } const res = await $fetch('/api/auth/passkeys/registration-options', registrationOptionsRequest)