mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add nuxt and expo with orpc
This commit is contained in:
43
apps/cli/templates/auth/web/nuxt/app/components/UserMenu.vue
Normal file
43
apps/cli/templates/auth/web/nuxt/app/components/UserMenu.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
// import { authClient } from "~/lib/auth-client";
|
||||
const {$authClient} = useNuxtApp()
|
||||
const session = $authClient.useSession()
|
||||
const toast = useToast()
|
||||
|
||||
const handleSignOut = async () => {
|
||||
try {
|
||||
await $authClient.signOut({
|
||||
fetchOptions: {
|
||||
onSuccess: async () => {
|
||||
toast.add({ title: 'Signed out successfully' })
|
||||
await navigateTo('/', { replace: true, external: true })
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.add({ title: 'Sign out failed', description: error?.error?.message || 'Unknown error'})
|
||||
}
|
||||
},
|
||||
})
|
||||
} catch (error: any) {
|
||||
toast.add({ title: 'An unexpected error occurred during sign out', description: error.message || 'Please try again.'})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<USkeleton v-if="session.isPending" class="h-9 w-24" />
|
||||
|
||||
<UButton v-else-if="!session.data" variant="outline" to="/login">
|
||||
Sign In
|
||||
</UButton>
|
||||
|
||||
<UButton
|
||||
v-else
|
||||
variant="solid"
|
||||
icon="i-lucide-log-out"
|
||||
label="Sign out"
|
||||
@click="handleSignOut()"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user