返回 presentation-ai
page.tsx
根目录 / src / app / auth / signin / page.tsx
1 "use client";
2
3 import { Button } from "@/components/ui/button";
4 import {
5 Card,
6 CardContent,
7 CardDescription,
8 CardFooter,
9 CardHeader,
10 CardTitle,
11 } from "@/components/ui/card";
12 import { signIn } from "next-auth/react";
13 import { useSearchParams } from "next/navigation";
14 import { FaGoogle } from "react-icons/fa";
15
16 export default function SignIn() {
17 const searchParams = useSearchParams();
18 const callbackUrl = searchParams.get("callbackUrl") ?? "/";
19 const error = searchParams.get("error");
20
21 const handleSignIn = async (provider: string) => {
22 await signIn(provider, { callbackUrl });
23 };
24
25 return (
26 <div className="flex min-h-screen items-center justify-center bg-gray-50 dark:bg-slate-900 px-4">
27 <Card className="w-full max-w-md shadow-lg">
28 <CardHeader className="space-y-1 text-center">
29 <CardTitle className="text-2xl font-bold">Welcome back</CardTitle>
30 <CardDescription>Sign in to your account to continue</CardDescription>
31 {error && (
32 <div
33 className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
34 role="alert"
35 >
36 <span className="block sm:inline">
37 Authentication error. Please try again.
38 </span>
39 </div>
40 )}
41 </CardHeader>
42 <CardContent className="grid gap-4">
43 <Button
44 variant="outline"
45 className="flex items-center justify-center gap-2"
46 onClick={() => handleSignIn("google")}
47 >
48 <FaGoogle className="h-4 w-4" />
49 Sign in with Google
50 </Button>
51 </CardContent>
52 <CardFooter className="flex flex-col items-center justify-center gap-2">
53 <p className="text-sm text-gray-500 dark:text-gray-400">
54 By signing in, you agree to our Terms of Service and Privacy Policy.
55 </p>
56 </CardFooter>
57 </Card>
58 </div>
59 );
60 }
61
61 lines Plain Text