diff --git a/src/modules/base/components/ProfileSettings.vue b/src/modules/base/components/ProfileSettings.vue index d1dab22..fed1828 100644 --- a/src/modules/base/components/ProfileSettings.vue +++ b/src/modules/base/components/ProfileSettings.vue @@ -147,6 +147,34 @@ Use the "Broadcast to Nostr" button to manually re-broadcast your profile.

+ + + +
+ + + + + + + Log out of {{ user?.username || 'your account' }}? + + You'll need to sign in again to access your wallet, post in the + forum, place orders, or use any feature that needs your account. + + + + Cancel + + Log out + + + + +
@@ -168,14 +196,28 @@ import { FormMessage, } from '@/components/ui/form' import ImageUpload from './ImageUpload.vue' +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from '@/components/ui/alert-dialog' +import { LogOut } from 'lucide-vue-next' import { useAuth } from '@/composables/useAuthService' +import { useRouter } from 'vue-router' import { injectService, SERVICE_TOKENS } from '@/core/di-container' import type { ImageUploadService } from '../services/ImageUploadService' import type { NostrMetadataService } from '../nostr/nostr-metadata-service' import { useToast } from '@/core/composables/useToast' // Services -const { user, updateProfile } = useAuth() +const { user, updateProfile, logout } = useAuth() +const router = useRouter() const imageService = injectService(SERVICE_TOKENS.IMAGE_UPLOAD_SERVICE) const metadataService = injectService(SERVICE_TOKENS.NOSTR_METADATA_SERVICE) const toast = useToast() @@ -322,4 +364,17 @@ const broadcastMetadata = async () => { isBroadcasting.value = false } } + +// Log out + redirect to /login on this app's origin. +const onLogout = async () => { + try { + await logout() + toast.success('Logged out') + router.push('/login') + } catch (error) { + const errorMessage = error instanceof Error ? error.message : 'Failed to log out' + console.error('Error logging out:', error) + toast.error(`Logout failed: ${errorMessage}`) + } +}