mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-26 22:26:10 +00:00
Update auth chapter (#983)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import AcmeLogo from '@/app/ui/acme-logo';
|
||||
import LoginForm from '@/app/ui/login-form';
|
||||
import { Suspense } from 'react';
|
||||
|
||||
export default function LoginPage() {
|
||||
return (
|
||||
@@ -10,7 +11,9 @@ export default function LoginPage() {
|
||||
<AcmeLogo />
|
||||
</div>
|
||||
</div>
|
||||
<LoginForm />
|
||||
<Suspense>
|
||||
<LoginForm />
|
||||
</Suspense>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function SideNav() {
|
||||
<form
|
||||
action={async () => {
|
||||
'use server';
|
||||
await signOut();
|
||||
await signOut({ redirectTo: '/' });
|
||||
}}
|
||||
>
|
||||
<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">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use client';
|
||||
|
||||
import { authenticate } from '@/app/lib/actions';
|
||||
import { lusitana } from '@/app/ui/fonts';
|
||||
import {
|
||||
AtSymbolIcon,
|
||||
@@ -8,10 +7,14 @@ import {
|
||||
ExclamationCircleIcon,
|
||||
} from '@heroicons/react/24/outline';
|
||||
import { ArrowRightIcon } from '@heroicons/react/20/solid';
|
||||
import { Button } from './button';
|
||||
import { Button } from '@/app/ui/button';
|
||||
import { useActionState } from 'react';
|
||||
import { authenticate } from '@/app/lib/actions';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
|
||||
export default function LoginForm() {
|
||||
const searchParams = useSearchParams();
|
||||
const callbackUrl = searchParams.get('callbackUrl') || '/dashboard';
|
||||
const [errorMessage, formAction, isPending] = useActionState(
|
||||
authenticate,
|
||||
undefined,
|
||||
@@ -64,6 +67,7 @@ export default function LoginForm() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="redirectTo" value={callbackUrl} />
|
||||
<Button className="mt-4 w-full" aria-disabled={isPending}>
|
||||
Log in <ArrowRightIcon className="ml-auto h-5 w-5 text-gray-50" />
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user