From dcb419d67a7cb2627619e6d90032199029a31c08 Mon Sep 17 00:00:00 2001 From: Dorian Date: Thu, 12 Feb 2026 13:20:35 +0000 Subject: [PATCH] Unify auth: bridge auth store and Nostr account on every login path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The app had two disconnected auth systems: - Auth store (useAuth): controls isAuthenticated, subscription, My List - Account manager (useAccounts): controls isNostrLoggedIn, comments Previously each login path only populated one system: - Persona login → Nostr only (no subscription/My List) - AuthModal Nostr → Auth store only (no commenting) - Extension login → Nostr only (no subscription/My List) Now every login path bridges both systems: - Persona/extension login also calls auth store loginWithNostr - AuthModal Nostr login also registers extension in accountManager - Logout already cleared both (no change needed) Co-authored-by: Cursor --- src/components/AppHeader.vue | 20 +++++++++++++++++++- src/components/AuthModal.vue | 11 ++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue index 9e2d2f9..b63e6e7 100644 --- a/src/components/AppHeader.vue +++ b/src/components/AppHeader.vue @@ -213,6 +213,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue' import { useRouter, useRoute } from 'vue-router' import { useAuth } from '../composables/useAuth' import { useAccounts } from '../composables/useAccounts' +import { accountManager } from '../lib/accounts' import { useContentDiscovery } from '../composables/useContentDiscovery' type Persona = { name: string; nsec: string; pubkey: string } @@ -237,7 +238,7 @@ const emit = defineEmits() const router = useRouter() const route = useRoute() -const { user, isAuthenticated, logout: appLogout } = useAuth() +const { user, isAuthenticated, loginWithNostr: appLoginWithNostr, logout: appLogout } = useAuth() const { isLoggedIn: nostrLoggedIn, activePubkey: nostrActivePubkey, @@ -347,11 +348,28 @@ function navigateTo(path: string) { async function handlePersonaLogin(persona: Persona) { personaMenuOpen.value = false + // Set up Nostr account (for commenting/reactions) await loginWithPersona(persona) + // Also populate auth store (for subscription/My List access) + try { + await appLoginWithNostr(persona.pubkey, 'persona', {}) + } catch { + // Auth store mock login — non-critical if it fails + } } async function handleExtensionLogin() { + // Set up Nostr account (for commenting/reactions) await loginWithExtension() + // Also populate auth store (for subscription/My List access) + try { + const pubkey = accountManager.active?.pubkey + if (pubkey) { + await appLoginWithNostr(pubkey, 'extension', {}) + } + } catch { + // Auth store mock login — non-critical if it fails + } } async function handleLogout() { diff --git a/src/components/AuthModal.vue b/src/components/AuthModal.vue index 32379d9..444c1b1 100644 --- a/src/components/AuthModal.vue +++ b/src/components/AuthModal.vue @@ -122,6 +122,7 @@