This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { auth, signIn } from "@/auth"
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card"
|
||||
import { isAdminEmail } from "@/lib/admin-auth"
|
||||
|
||||
async function signInWithGoogle() {
|
||||
"use server"
|
||||
|
||||
await signIn("google", { redirectTo: "/admin" })
|
||||
}
|
||||
|
||||
export default async function SignInPage() {
|
||||
const session = await auth()
|
||||
|
||||
if (isAdminEmail(session?.user?.email)) {
|
||||
redirect("/admin")
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen items-center justify-center bg-muted px-6 py-12">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader>
|
||||
<CardTitle>Wedding admin</CardTitle>
|
||||
<CardDescription>
|
||||
Sign in with an authorized Google account to manage invitations.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
<Alert>
|
||||
<AlertTitle>Private area</AlertTitle>
|
||||
<AlertDescription>
|
||||
Access is restricted to the admin emails configured for this wedding.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
<form action={signInWithGoogle}>
|
||||
<Button className="w-full" type="submit">
|
||||
Continue with Google
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user