MCPcopy Create free account
hub / github.com/code-with-antonio/nodebase / LoginForm

Function LoginForm

src/features/auth/components/login-form.tsx:36–179  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34type LoginFormValues = z.infer<typeof loginSchema>;
35
36export function LoginForm() {
37 const router = useRouter();
38
39 const form = useForm<LoginFormValues>({
40 resolver: zodResolver(loginSchema),
41 defaultValues: {
42 email: "",
43 password: "",
44 },
45 });
46
47 const signInGithub = async () => {
48 await authClient.signIn.social({
49 provider: "github",
50 }, {
51 onSuccess: () => {
52 router.push("/");
53 },
54 onError: () => {
55 toast.error("Something went wrong");
56 },
57 });
58 };
59
60 const signInGoogle = async () => {
61 await authClient.signIn.social({
62 provider: "google",
63 }, {
64 onSuccess: () => {
65 router.push("/");
66 },
67 onError: () => {
68 toast.error("Something went wrong");
69 },
70 });
71 };
72
73 const onSubmit = async (values: LoginFormValues) => {
74 await authClient.signIn.email({
75 email: values.email,
76 password: values.password,
77 callbackURL: "/",
78 }, {
79 onSuccess: () => {
80 router.push("/");
81 },
82 onError: (ctx) => {
83 toast.error(ctx.error.message);
84 },
85 });
86 };
87
88 const isPending = form.formState.isSubmitting;
89
90 return (
91 <div className="flex flex-col gap-6">
92 <Card>
93 <CardHeader className="text-center">

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected