Unify auth: bridge auth store and Nostr account on every login path
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 <cursoragent@cursor.com>
This commit is contained in:
@@ -122,6 +122,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { useAuth } from '../composables/useAuth'
|
||||
import { useAccounts } from '../composables/useAccounts'
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
@@ -140,6 +141,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const { login, loginWithNostr, register, isLoading: authLoading } = useAuth()
|
||||
const { loginWithExtension } = useAccounts()
|
||||
|
||||
const mode = ref<'login' | 'register' | 'forgot'>(props.defaultMode)
|
||||
const formData = ref({
|
||||
@@ -206,9 +208,16 @@ async function handleNostrLogin() {
|
||||
// Sign event with extension
|
||||
const signedEvent = await window.nostr.signEvent(authEvent)
|
||||
|
||||
// Create session with backend
|
||||
// Create session with backend (auth store — subscription/My List)
|
||||
await loginWithNostr(pubkey, signedEvent.sig, signedEvent)
|
||||
|
||||
// Also register extension account in accountManager (commenting/reactions)
|
||||
try {
|
||||
await loginWithExtension()
|
||||
} catch {
|
||||
// Non-critical — extension account already obtained pubkey above
|
||||
}
|
||||
|
||||
emit('success')
|
||||
closeModal()
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user