From 70737561172449c431beadf99f70743d3cd51e8a Mon Sep 17 00:00:00 2001 From: Till JS Date: Thu, 26 Mar 2026 21:15:09 +0100 Subject: [PATCH] feat(auth): UX improvements for passkeys, 2FA, and password management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Passkey Conditional UI: autocomplete="username webauthn" on email field enables browser passkey suggestions in autofill dropdown 2. Trust Device checkbox: "Diesem Gerät 30 Tage vertrauen" option during 2FA verification (uses Better Auth trust_device cookie) 3. Local QR code generation: replaced external api.qrserver.com with local qrcode package for 2FA setup (no external dependency) 4. SecurityOnboarding component: post-registration wizard suggesting passkey setup to new users 5. ChangePassword component: reusable password change form with validation, visibility toggles, and changePassword() in authService Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/shared-auth-ui/package.json | 8 +- .../src/components/ChangePassword.svelte | 355 ++++++++++++++++++ .../src/components/SecurityOnboarding.svelte | 348 +++++++++++++++++ .../src/components/TwoFactorSetup.svelte | 38 +- packages/shared-auth-ui/src/index.ts | 2 + .../shared-auth-ui/src/pages/LoginPage.svelte | 21 +- packages/shared-auth/src/core/authService.ts | 31 ++ pnpm-lock.yaml | 308 ++++++--------- 8 files changed, 903 insertions(+), 208 deletions(-) create mode 100644 packages/shared-auth-ui/src/components/ChangePassword.svelte create mode 100644 packages/shared-auth-ui/src/components/SecurityOnboarding.svelte diff --git a/packages/shared-auth-ui/package.json b/packages/shared-auth-ui/package.json index 60ed217bf..34772fe76 100644 --- a/packages/shared-auth-ui/package.json +++ b/packages/shared-auth-ui/package.json @@ -21,13 +21,17 @@ "lint": "eslint ." }, "peerDependencies": { - "svelte": "^5.0.0", "@manacore/shared-auth": "workspace:*", + "@manacore/shared-branding": "workspace:*", "@manacore/shared-icons": "workspace:*", - "@manacore/shared-branding": "workspace:*" + "svelte": "^5.0.0" }, "devDependencies": { + "@types/qrcode": "^1.5.5", "svelte": "^5.16.0", "typescript": "^5.7.3" + }, + "dependencies": { + "qrcode": "^1.5.4" } } diff --git a/packages/shared-auth-ui/src/components/ChangePassword.svelte b/packages/shared-auth-ui/src/components/ChangePassword.svelte new file mode 100644 index 000000000..b60f4f45f --- /dev/null +++ b/packages/shared-auth-ui/src/components/ChangePassword.svelte @@ -0,0 +1,355 @@ + + +
+

Passwort ändern

+ + {#if success} +
+

Passwort erfolgreich geändert.

+
+ {/if} + + {#if error} + + {/if} + +
{ + e.preventDefault(); + handleSubmit(); + }} + > +
+ +
+ + +
+
+ +
+ +
+ 0 && !passwordLongEnough} + style:--ring-color={primaryColor} + /> + +
+ {#if newPassword.length > 0 && !passwordLongEnough} +

Mindestens 8 Zeichen

+ {:else} +

Mindestens 8 Zeichen

+ {/if} +
+ +
+ +
+ 0 && !passwordsMatch} + style:--ring-color={primaryColor} + /> + +
+ {#if confirmPassword.length > 0 && !passwordsMatch} +

Passwörter stimmen nicht überein

+ {/if} +
+ + +
+
+ + diff --git a/packages/shared-auth-ui/src/components/SecurityOnboarding.svelte b/packages/shared-auth-ui/src/components/SecurityOnboarding.svelte new file mode 100644 index 000000000..ccabdf52b --- /dev/null +++ b/packages/shared-auth-ui/src/components/SecurityOnboarding.svelte @@ -0,0 +1,348 @@ + + +
+ {#if success} +
+
+ + + +
+

Passkey eingerichtet!

+

+ Dein Konto ist jetzt mit einem Passkey gesichert. Du kannst dich ab sofort ohne Passwort + anmelden. +

+ +
+ {:else} +
+
+ + + + +
+

Sichere dein Konto

+

Schütze dein Konto mit zusätzlicher Sicherheit.

+ + {#if error} + + {/if} + + {#if passkeyAvailable && onSetupPasskey} +
+
+ + + + +
+
+

Passkey einrichten

+

+ Anmelden ohne Passwort mit Touch ID, Face ID oder Windows Hello +

+
+ +
+ {/if} + +

Du kannst 2FA jederzeit in den Einstellungen aktivieren.

+ + +
+ {/if} +
+ + diff --git a/packages/shared-auth-ui/src/components/TwoFactorSetup.svelte b/packages/shared-auth-ui/src/components/TwoFactorSetup.svelte index 59c27e733..516a66237 100644 --- a/packages/shared-auth-ui/src/components/TwoFactorSetup.svelte +++ b/packages/shared-auth-ui/src/components/TwoFactorSetup.svelte @@ -1,4 +1,5 @@