change our current auth system for NextAuth.js (now Auth.js): This is th
This commit is contained in:
+12
-13
@@ -4,15 +4,14 @@ import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { signIn, getSession } from '@/lib/auth';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { signIn } from '@/app/api/auth/[...nextauth]/route';
|
||||
|
||||
async function handleSignIn(formData: FormData) {
|
||||
'use server';
|
||||
await signIn('credentials', formData);
|
||||
}
|
||||
|
||||
export default async function LoginPage() {
|
||||
const session = await getSession();
|
||||
if (session) {
|
||||
redirect('/admin');
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center bg-background">
|
||||
<Card className="w-full max-w-sm">
|
||||
@@ -21,7 +20,7 @@ export default async function LoginPage() {
|
||||
<CardDescription>Enter your credentials to access the dashboard.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form action={signIn} className="grid gap-4">
|
||||
<form action={handleSignIn} className="grid gap-4">
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Input
|
||||
@@ -35,11 +34,11 @@ export default async function LoginPage() {
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="password">Password</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
name="password"
|
||||
required
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
name="password"
|
||||
required
|
||||
defaultValue="password"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user