Skip to content

Commit 8e7ef0a

Browse files
b-at-neuclaude
andcommitted
#240 address review feedback cycle 4
Restore name gate in auth layout so every authenticated-nameless user is redirected to /login regardless of entry point. Add redirectTo prop to NameField so post-name navigation honors the original destination. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a42ba09 commit 8e7ef0a

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

app/(main)/(auth)/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export default async function AuthGateLayout({
1313
}) {
1414
const user = await getCurrentUser();
1515

16+
// Name gate — nameless users must set their name before accessing any app route.
17+
if (!user.name?.trim()) redirect('/login');
18+
1619
if (user.isAdmin) return <>{children}</>;
1720

1821
if (await isManager(user.id)) return <>{children}</>;

app/login/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default async function SignInPage({
4040
return (
4141
<div className="flex w-full flex-col items-center gap-4">
4242
{user ? (
43-
<NameField defaultName={user.name ?? ''} />
43+
<NameField defaultName={user.name ?? ''} redirectTo={safeTo} />
4444
) : (
4545
<AuthView
4646
path="SIGN_IN"

components/features/name-field.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ type NameFormValues = z.infer<typeof nameSchema>;
4141

4242
interface NameFieldProps {
4343
defaultName: string;
44+
redirectTo: string;
4445
}
4546

46-
export function NameField({ defaultName }: NameFieldProps) {
47+
export function NameField({ defaultName, redirectTo }: NameFieldProps) {
4748
const router = useRouter();
4849
const [isPending, startTransition] = useTransition();
4950

@@ -69,7 +70,7 @@ export function NameField({ defaultName }: NameFieldProps) {
6970
);
7071
else toast.success('Name saved');
7172

72-
router.replace('/');
73+
router.replace(redirectTo);
7374
});
7475
}
7576

0 commit comments

Comments
 (0)