diff --git a/src/components/sign-in-form.tsx b/src/components/sign-in-form.tsx new file mode 100644 index 0000000..0f14526 --- /dev/null +++ b/src/components/sign-in-form.tsx @@ -0,0 +1,49 @@ +import { signIn } from "@/lib/auth"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Button } from "@/components/ui/button"; +import { GithubSignIn } from "@/components/github-sign-in"; + +export function SignInForm() { + return ( +
+
+

Sign in to your account

+

+ Enter your email below to sign in to your account +

+
+
{ + "use server"; + await signIn("credentials", formData); + }} + > +
+ + +
+
+ + +
+ +
+
+ + Or + +
+ +
+ Don't have an account?{" "} + + Sign up + +
+
+ ) +} diff --git a/src/components/sign-up-form.tsx b/src/components/sign-up-form.tsx new file mode 100644 index 0000000..ef64820 --- /dev/null +++ b/src/components/sign-up-form.tsx @@ -0,0 +1,63 @@ +import bcrypt from "bcrypt"; +import prisma from "@/lib/prisma"; +import { authSchema } from "@/lib/zod"; +import { redirect } from "next/navigation"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Button } from "@/components/ui/button"; +import { GithubSignIn } from "@/components/github-sign-in"; + +export function SignUpForm() { + return ( +
+
+

Sign up to your account

+

+ Enter your email below to sign up to your account +

+
+
{ + "use server"; + const email = formData.get("email"); + const password = formData.get("password"); + const validatedData = await authSchema.parseAsync({ email, password }); + const saltRounds = 10; + const pwHash = await bcrypt.hash(validatedData.password, saltRounds); + await prisma.user.create({ + data: { + email: validatedData.email, + password: pwHash + } + }) + redirect("/sign-in"); + }} + > +
+ + +
+
+ + +
+ +
+
+ + Or + +
+ +
+ Already have an account? {" "} + + Sign in + +
+
+ ) +}