Remove legacy Nostr keypair authentication and fix auth service integration
- Remove obsolete LogoutDialog component that displayed private keys - Replace nostrStore.account references with authService.user in market module - Fix property access paths to use authService.user.value instead of currentUser - Update connection state checks to use relayHub instead of nostrStore - Clean up TODOs and remove unused nostrStore imports
This commit is contained in:
parent
30b9089829
commit
92c33aa0a3
3 changed files with 9 additions and 125 deletions
|
|
@ -1,106 +0,0 @@
|
|||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useNostrStore } from '@/stores/nostr'
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { LogOut, Copy, Check, ShieldAlert } from 'lucide-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
const props = defineProps<{
|
||||
onLogout: () => void
|
||||
}>()
|
||||
|
||||
const nostrStore = useNostrStore()
|
||||
const isOpen = ref(false)
|
||||
const hasCopied = ref(false)
|
||||
|
||||
const copyPrivateKey = async () => {
|
||||
if (!nostrStore.account?.privkey) return
|
||||
|
||||
try {
|
||||
await navigator.clipboard.writeText(nostrStore.account.privkey)
|
||||
hasCopied.value = true
|
||||
setTimeout(() => {
|
||||
hasCopied.value = false
|
||||
}, 2000)
|
||||
} catch (err) {
|
||||
console.error('Failed to copy private key:', err)
|
||||
}
|
||||
}
|
||||
|
||||
const handleLogout = () => {
|
||||
isOpen.value = false
|
||||
props.onLogout()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="isOpen">
|
||||
<DialogTrigger as-child>
|
||||
<Button variant="ghost" size="icon" class="text-muted-foreground hover:text-foreground">
|
||||
<LogOut class="h-5 w-5" />
|
||||
<span class="sr-only">{{ t('nav.logout') }}</span>
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent class="sm:max-w-md">
|
||||
<DialogHeader class="space-y-4">
|
||||
<div class="mx-auto w-12 h-12 rounded-full bg-gradient-to-br from-primary to-primary/80 p-0.5">
|
||||
<div class="w-full h-full rounded-full bg-background flex items-center justify-center">
|
||||
<ShieldAlert class="h-6 w-6 text-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center space-y-2">
|
||||
<DialogTitle class="text-xl font-semibold text-foreground">
|
||||
{{ t('auth.logout.title') }}
|
||||
</DialogTitle>
|
||||
<DialogDescription class="text-muted-foreground">
|
||||
{{ t('auth.logout.description') }}
|
||||
</DialogDescription>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
<div class="flex flex-col gap-4 py-6">
|
||||
<Button class="w-full bg-muted hover:bg-muted/80 text-muted-foreground" variant="outline"
|
||||
@click="copyPrivateKey">
|
||||
<Copy v-if="!hasCopied" class="h-4 w-4 mr-2" />
|
||||
<Check v-else class="h-4 w-4 mr-2" />
|
||||
{{ hasCopied ? t('auth.logout.copied') : t('auth.logout.copyKey') }}
|
||||
</Button>
|
||||
</div>
|
||||
<DialogFooter class="flex flex-col sm:flex-row gap-2 sm:gap-3">
|
||||
<Button variant="ghost" @click="() => isOpen = false" class="flex-1 sm:flex-none hover:bg-muted">
|
||||
{{ t('auth.logout.cancel') }}
|
||||
</Button>
|
||||
<Button variant="destructive" @click="handleLogout" class="flex-1 sm:flex-none">
|
||||
<LogOut class="h-4 w-4 mr-2" />
|
||||
{{ t('auth.logout.confirm') }}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Improved focus styles */
|
||||
:focus-visible {
|
||||
outline: 2px solid hsl(var(--primary));
|
||||
outline-offset: 2px;
|
||||
transition: outline-offset 0.2s ease;
|
||||
}
|
||||
|
||||
/* Enhanced button hover states */
|
||||
button:not(:disabled):hover {
|
||||
transform: translateY(-1px) scale(1.01);
|
||||
}
|
||||
|
||||
button:not(:disabled):active {
|
||||
transform: translateY(0) scale(0.99);
|
||||
}
|
||||
|
||||
/* Smooth transitions */
|
||||
* {
|
||||
transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, filter;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transition-duration: 300ms;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import { ref, computed, onMounted, onUnmounted, readonly } from 'vue'
|
||||
import { useNostrStore } from '@/stores/nostr'
|
||||
import { useMarketStore } from '../stores/market'
|
||||
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
||||
import { config } from '@/lib/config'
|
||||
|
|
@ -16,7 +15,6 @@ const MARKET_EVENT_KINDS = {
|
|||
} as const
|
||||
|
||||
export function useMarket() {
|
||||
const nostrStore = useNostrStore()
|
||||
const marketStore = useMarketStore()
|
||||
const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB) as any
|
||||
const authService = injectService(SERVICE_TOKENS.AUTH_SERVICE) as any
|
||||
|
|
@ -61,7 +59,7 @@ export function useMarket() {
|
|||
const connectionStatus = computed(() => {
|
||||
if (connectionOperation.isLoading.value) return 'connecting'
|
||||
if (isConnected.value) return 'connected'
|
||||
if (connectionOperation.error.value || nostrStore.error) return 'error'
|
||||
if (connectionOperation.error.value || authService.error) return 'error'
|
||||
return 'disconnected'
|
||||
})
|
||||
|
||||
|
|
@ -69,10 +67,9 @@ export function useMarket() {
|
|||
const loadMarket = async (naddr: string) => {
|
||||
return await marketOperation.execute(async () => {
|
||||
// Parse naddr to get market data
|
||||
// TODO: Confirm if this should use nostrStore.account?.pubkey or authService.user.value?.pubkey
|
||||
const marketData = {
|
||||
identifier: naddr.split(':')[2] || 'default',
|
||||
pubkey: naddr.split(':')[1] || nostrStore.account?.pubkey || ''
|
||||
pubkey: naddr.split(':')[1] || authService.user.value?.pubkey || ''
|
||||
}
|
||||
|
||||
if (!marketData.pubkey) {
|
||||
|
|
@ -349,11 +346,9 @@ export function useMarket() {
|
|||
// Subscribe to order-related DMs (payment requests, status updates)
|
||||
const subscribeToOrderUpdates = (): (() => void) | null => {
|
||||
try {
|
||||
// TODO: Confirm if this should use nostrStore.account?.pubkey or authService.user.value?.pubkey
|
||||
const userPubkey = nostrStore.account?.pubkey || authService.user.value?.pubkey
|
||||
const userPubkey = authService.user.value?.pubkey
|
||||
if (!userPubkey) {
|
||||
console.warn('Cannot subscribe to order updates: no user pubkey available', {
|
||||
nostrStorePubkey: nostrStore.account?.pubkey,
|
||||
authServicePubkey: authService.user.value?.pubkey,
|
||||
isAuthenticated: authService.isAuthenticated.value
|
||||
})
|
||||
|
|
@ -389,12 +384,10 @@ export function useMarket() {
|
|||
try {
|
||||
console.log('🔔 Received order-related DM:', event.id, 'from:', event.pubkey.slice(0, 8))
|
||||
|
||||
// TODO: Confirm if this should use nostrStore.account?.pubkey or authService.user.value?.pubkey
|
||||
const userPrivkey = nostrStore.account?.privkey || authService.user.value?.prvkey
|
||||
const userPrivkey = authService.user.value?.prvkey
|
||||
|
||||
if (!userPrivkey) {
|
||||
console.warn('Cannot decrypt DM: no user private key available', {
|
||||
nostrStorePrivkey: !!nostrStore.account?.privkey,
|
||||
authServicePrivkey: !!authService.user.value?.prvkey
|
||||
})
|
||||
return
|
||||
|
|
@ -575,10 +568,9 @@ export function useMarket() {
|
|||
|
||||
// Load market data
|
||||
console.log('🛒 Loading basic market data...')
|
||||
// TODO: Confirm if this should use nostrStore.account?.pubkey or authService.user.value?.pubkey
|
||||
await loadMarketData({
|
||||
identifier: 'default',
|
||||
pubkey: nostrStore.account?.pubkey || ''
|
||||
pubkey: authService.user.value?.pubkey || ''
|
||||
})
|
||||
|
||||
// Load stalls and products only if connected
|
||||
|
|
@ -614,7 +606,7 @@ export function useMarket() {
|
|||
|
||||
// Initialize market on mount
|
||||
onMounted(async () => {
|
||||
if (nostrStore.isConnected) {
|
||||
if (relayHub.isConnected.value) {
|
||||
await connectToMarket()
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -272,7 +272,6 @@
|
|||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useMarketStore } from '@/stores/market'
|
||||
import { useNostrStore } from '@/stores/nostr'
|
||||
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
||||
import {
|
||||
Card,
|
||||
|
|
@ -292,7 +291,6 @@ import {
|
|||
|
||||
const route = useRoute()
|
||||
const marketStore = useMarketStore()
|
||||
const nostrStore = useNostrStore()
|
||||
const authService = injectService(SERVICE_TOKENS.AUTH_SERVICE) as any
|
||||
|
||||
// State
|
||||
|
|
@ -417,11 +415,11 @@ const placeOrder = async () => {
|
|||
isAuthenticated: authService.isAuthenticated.value,
|
||||
user: authService.user.value,
|
||||
hasPubkey: !!authService.user.value?.pubkey,
|
||||
nostrPubkey: nostrStore.account?.pubkey
|
||||
nostrPubkey: authService.user.value?.pubkey
|
||||
})
|
||||
|
||||
// Get pubkey from auth service or fallback to nostr store
|
||||
const userPubkey = authService.user.value?.pubkey || nostrStore.account?.pubkey
|
||||
// Get pubkey from auth service
|
||||
const userPubkey = authService.user.value?.pubkey
|
||||
|
||||
if (!authService.isAuthenticated.value) {
|
||||
throw new Error('You must be logged in to place an order')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue