diff --git a/components/dashboard/TheHeader.vue b/components/dashboard/TheHeader.vue index 8f0f33f..81b2130 100644 --- a/components/dashboard/TheHeader.vue +++ b/components/dashboard/TheHeader.vue @@ -6,15 +6,22 @@ const props = defineProps<{ name: string | null }>() const config = useRuntimeConfig() +const { $client } = useNuxtApp() const menuVisible = ref(false) const menu = ref() const items = ref([ { label: 'Logout', + command: logout, }, ]) +async function logout() { + await $client.auth.email.logout.mutate() + navigateTo('/login') +} + function toggle(event: any) { menu.value.toggle(event) } diff --git a/server/trpc/routers/auth/email.ts b/server/trpc/routers/auth/email.ts index 8ed0d1b..03cfe17 100644 --- a/server/trpc/routers/auth/email.ts +++ b/server/trpc/routers/auth/email.ts @@ -58,6 +58,11 @@ export const emailSessionRouter = router({ }) return email }), + logout: publicProcedure + .mutation(async ({ ctx }) => { + await ctx.session.clear() + return true + }), verifyOtp: publicProcedure .input( z.object({