"use client"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import { useState, useTransition } from "react"; import { Loader2 } from "lucide-react"; import { client, signIn } from "@/lib/auth-client"; import Link from "next/link"; import { cn } from "@/lib/utils"; import { useRouter, useSearchParams } from "next/navigation"; import { toast } from "sonner"; import { getCallbackURL } from "@/lib/shared"; export default function SignIn() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [loading, startTransition] = useTransition(); const [rememberMe, setRememberMe] = useState(false); const router = useRouter(); const params = useSearchParams(); const LastUsedIndicator = () => ( Last Used ); return ( Sign In Enter your email below to login to your account Email { setEmail(e.target.value); }} value={email} /> Password Forgot your password? setPassword(e.target.value)} /> { setRememberMe(!rememberMe); }} /> Remember me { startTransition(async () => { await signIn.email( { email, password, rememberMe }, { onSuccess(context) { toast.success("Successfully signed in"); router.push(getCallbackURL(params)); }, onError(context) { toast.error(context.error.message); }, }, ); }); }} > {loading ? ( ) : ( "Login" )} {client.isLastUsedLoginMethod("email") && } { await signIn.social({ provider: "google", callbackURL: "/dashboard", }); }} > Sign in with Google {client.isLastUsedLoginMethod("google") && } { await signIn.social({ provider: "github", callbackURL: "/dashboard", }); }} > Sign in with GitHub {client.isLastUsedLoginMethod("github") && } { await signIn.social({ provider: "microsoft", callbackURL: "/dashboard", }); }} > Sign in with Microsoft {client.isLastUsedLoginMethod("microsoft") && ( )} built with{" "} better-auth. ); }
built with{" "} better-auth.