Skip to content

Commit e0936ed

Browse files
b-at-neuclaude
andcommitted
#285 address review feedback cycle 1
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f74a689 commit e0936ed

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

components/layouts/user-menu.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { signOutUser } from '@/prisma/actions/auth';
1919
import { logoutBypassUser } from '@/prisma/services/dev-bypass';
2020

2121
import type { NavIdentity } from '@/lib/types';
22+
import { isError } from '@/lib/utils';
2223

2324
import {
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.

prisma/actions/auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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.
1313
export 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

0 commit comments

Comments
 (0)