Skip to content

Commit fc6c41c

Browse files
authored
Update auth chapter (#983)
1 parent 7295dab commit fc6c41c

File tree

7 files changed

+421
-408
lines changed

7 files changed

+421
-408
lines changed

dashboard/final-example/app/login/page.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import AcmeLogo from '@/app/ui/acme-logo';
22
import LoginForm from '@/app/ui/login-form';
3+
import { Suspense } from 'react';
34

45
export default function LoginPage() {
56
return (
@@ -10,7 +11,9 @@ export default function LoginPage() {
1011
<AcmeLogo />
1112
</div>
1213
</div>
13-
<LoginForm />
14+
<Suspense>
15+
<LoginForm />
16+
</Suspense>
1417
</div>
1518
</main>
1619
);

dashboard/final-example/app/ui/dashboard/sidenav.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function SideNav() {
2121
<form
2222
action={async () => {
2323
'use server';
24-
await signOut();
24+
await signOut({ redirectTo: '/' });
2525
}}
2626
>
2727
<button className="flex h-[48px] w-full grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 text-sm font-medium hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3">

dashboard/final-example/app/ui/login-form.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
'use client';
22

3-
import { authenticate } from '@/app/lib/actions';
43
import { lusitana } from '@/app/ui/fonts';
54
import {
65
AtSymbolIcon,
76
KeyIcon,
87
ExclamationCircleIcon,
98
} from '@heroicons/react/24/outline';
109
import { ArrowRightIcon } from '@heroicons/react/20/solid';
11-
import { Button } from './button';
10+
import { Button } from '@/app/ui/button';
1211
import { useActionState } from 'react';
12+
import { authenticate } from '@/app/lib/actions';
13+
import { useSearchParams } from 'next/navigation';
1314

1415
export default function LoginForm() {
16+
const searchParams = useSearchParams();
17+
const callbackUrl = searchParams.get('callbackUrl') || '/dashboard';
1518
const [errorMessage, formAction, isPending] = useActionState(
1619
authenticate,
1720
undefined,
@@ -64,6 +67,7 @@ export default function LoginForm() {
6467
</div>
6568
</div>
6669
</div>
70+
<input type="hidden" name="redirectTo" value={callbackUrl} />
6771
<Button className="mt-4 w-full" aria-disabled={isPending}>
6872
Log in <ArrowRightIcon className="ml-auto h-5 w-5 text-gray-50" />
6973
</Button>

dashboard/final-example/package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
},
88
"dependencies": {
99
"@heroicons/react": "^2.2.0",
10-
"@tailwindcss/forms": "^0.5.9",
10+
"@tailwindcss/forms": "^0.5.10",
1111
"@vercel/postgres": "^0.10.0",
1212
"autoprefixer": "10.4.20",
1313
"bcrypt": "^5.1.1",
1414
"clsx": "^2.1.1",
15-
"next": "latest",
16-
"next-auth": "5.0.0-beta.19",
17-
"postcss": "8.4.49",
15+
"next": "^15.1.5",
16+
"next-auth": "5.0.0-beta.25",
17+
"postcss": "8.5.1",
1818
"react": "19.0.0",
1919
"react-dom": "19.0.0",
20-
"tailwindcss": "3.4.16",
21-
"typescript": "5.7.2",
20+
"tailwindcss": "3.4.17",
21+
"typescript": "5.7.3",
2222
"use-debounce": "^10.0.4",
23-
"zod": "^3.23.8"
23+
"zod": "^3.24.1"
2424
},
2525
"devDependencies": {
2626
"@types/bcrypt": "^5.0.2",
27-
"@types/node": "22.10.1",
28-
"@types/react": "19.0.0",
29-
"@types/react-dom": "19.0.0"
27+
"@types/node": "22.10.7",
28+
"@types/react": "19.0.7",
29+
"@types/react-dom": "19.0.3"
3030
}
3131
}

0 commit comments

Comments
 (0)