File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { signOutUser } from '@/prisma/actions/auth';
1919import { logoutBypassUser } from '@/prisma/services/dev-bypass' ;
2020
2121import type { NavIdentity } from '@/lib/types' ;
22+ import { isError } from '@/lib/utils' ;
2223
2324import {
2425 DropdownMenu ,
@@ -72,8 +73,11 @@ export function UserMenu({
7273 await logoutBypassUser ( ) ;
7374 return ;
7475 }
76+ // Optimistic success toast — fires before the server redirect so it
77+ // displays regardless of which path (redirect or error) completes first.
78+ toast . success ( 'Signed out.' ) ;
7579 const result = await signOutUser ( ) ;
76- if ( result && 'error' in result ) {
80+ if ( isError ( result ) ) {
7781 toast . error ( result . error ) ;
7882 }
7983 // On success the server action redirects to /login — no client navigation needed.
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import type { ErrorType } from '@/lib/utils';
1212// fragility that caused the 403 when sign-out was driven client-side.
1313export async function signOutUser ( ) : Promise < ErrorType | void > {
1414 const user = await getCurrentUser ( ) ;
15- if ( ! user ) redirect ( '/login' ) ;
15+ // getCurrentUser() always redirects when unauthenticated; this throw is defense-in-depth.
16+ if ( ! user ) throw new Error ( 'Unauthenticated' ) ;
1617
1718 const result = await authServer . signOut ( ) ;
1819
You can’t perform that action at this time.
0 commit comments