From a6962a64e10dfabcd51422c6a33b493634aedea9 Mon Sep 17 00:00:00 2001 From: Kenan KARAER Date: Wed, 3 Dec 2025 23:04:56 +0300 Subject: [PATCH] Feat: Implement sign out functionality in UserNav --- src/app/(auth)/actions.ts | 10 ++++++++++ src/components/user-nav.tsx | 24 ++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 src/app/(auth)/actions.ts diff --git a/src/app/(auth)/actions.ts b/src/app/(auth)/actions.ts new file mode 100644 index 0000000..2d4aa6b --- /dev/null +++ b/src/app/(auth)/actions.ts @@ -0,0 +1,10 @@ +'use server' + +import { createClient } from "@/lib/supabase/server" +import { redirect } from "next/navigation" + +export async function signOut() { + const supabase = await createClient() + await supabase.auth.signOut() + redirect('/login') +} diff --git a/src/components/user-nav.tsx b/src/components/user-nav.tsx index 1c26bcc..0420d8a 100644 --- a/src/components/user-nav.tsx +++ b/src/components/user-nav.tsx @@ -1,3 +1,5 @@ +'use client' + import { Avatar, AvatarFallback, @@ -14,8 +16,16 @@ import { DropdownMenuShortcut, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" +import { signOut } from "@/app/(auth)/actions" +import { useRouter } from "next/navigation" export function UserNav() { + const router = useRouter() + + const handleSignOut = async () => { + await signOut() + } + return ( @@ -29,27 +39,21 @@ export function UserNav() {
-

Admin

+

Kullanıcı

- admin@example.com + Hesabım

- - Profil - ⇧⌘P - - + router.push('/dashboard/settings')}> Ayarlar - ⌘S - + Çıkış Yap - ⇧⌘Q