diff --git a/src/app/auth/layout.tsx b/src/app/auth/layout.tsx
deleted file mode 100644
index 5aec572..0000000
--- a/src/app/auth/layout.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import React from 'react';
-
-export default function AuthLayout({
- children,
-}: Readonly<{
- children: React.ReactNode;
-}>) {
- return (
-
- {children}
-
- );
-}
diff --git a/src/app/auth/signin/page.tsx b/src/app/auth/signin/page.tsx
deleted file mode 100644
index 2660cbe..0000000
--- a/src/app/auth/signin/page.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import React from 'react';
-import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
-import SignInForm from '@/components/form/signInForm';
-import signIn from '@/lib/actions/signIn';
-import Link from 'next/link';
-import { URL_SIGN_UP } from '@/lib/constants';
-
-export default async function SignInPage() {
- return (
-
-
- Sign in
- Sign into your existing account
-
-
-
-
-
-
- Don't have an account? Sign up
-
-
-
- );
-}
diff --git a/src/app/auth/signup/page.tsx b/src/app/auth/signup/page.tsx
deleted file mode 100644
index 33ef08d..0000000
--- a/src/app/auth/signup/page.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import React from 'react';
-import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
-import signUp from '@/lib/actions/signUp';
-import SignUpForm from '@/components/form/signUpForm';
-import Link from 'next/link';
-import { URL_SIGN_IN } from '@/lib/constants';
-
-export default async function SignUpPage() {
- return (
-
-
- Sign up
- Create a new account.
-
-
-
-
-
-
- Already have an account? Sign in
-
-
-
- );
-}
diff --git a/src/components/form/signInForm.tsx b/src/components/form/signInForm.tsx
deleted file mode 100644
index e4e96fa..0000000
--- a/src/components/form/signInForm.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-'use client';
-
-import { zodResolver } from '@hookform/resolvers/zod';
-import { useForm } from 'react-hook-form';
-import { z } from 'zod';
-import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
-import { Input } from '@/components/ui/input';
-import React from 'react';
-import { Button } from '@/components/ui/button';
-import { signInFormSchema } from '@/lib/form-schemas/signInFormSchema';
-import { ActionResponse } from '@/lib/types/actionResponse';
-import { useRouter } from 'next/navigation';
-import { toast } from 'sonner';
-import { sonnerContent } from '@/components/ui/sonner';
-
-export default function SignInForm({onSubmit}: {
- onSubmit: (data: z.infer) => Promise
-}) {
-
- const router = useRouter();
-
- const form = useForm>({
- resolver: zodResolver(signInFormSchema),
- defaultValues: {
- username: '',
- password: '',
- },
- });
-
- const handleSubmit = async (data: z.infer) => {
- const response = await onSubmit(data);
- toast(sonnerContent(response));
- if (response.redirect) {
- router.push(response.redirect);
- }
- };
-
- return (
-
-
- );
-}
diff --git a/src/components/form/signUpForm.tsx b/src/components/form/signUpForm.tsx
deleted file mode 100644
index 2898733..0000000
--- a/src/components/form/signUpForm.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-'use client';
-
-import { zodResolver } from '@hookform/resolvers/zod';
-import { useForm } from 'react-hook-form';
-import { z } from 'zod';
-import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
-import { Input } from '@/components/ui/input';
-import React from 'react';
-import { Button } from '@/components/ui/button';
-import { signUpFormSchema } from '@/lib/form-schemas/signUpFormSchema';
-import { ActionResponse } from '@/lib/types/actionResponse';
-import { useRouter } from 'next/navigation';
-import { toast } from 'sonner';
-import { sonnerContent } from '@/components/ui/sonner';
-
-export default function SignUpForm({onSubmit}: {
- onSubmit: (data: z.infer) => Promise
-}) {
-
- const router = useRouter();
-
- const form = useForm>({
- resolver: zodResolver(signUpFormSchema),
- defaultValues: {
- username: '',
- password: '',
- },
- });
-
- const handleSubmit = async (data: z.infer) => {
- const response = await onSubmit(data);
- toast(sonnerContent(response));
- if (response.redirect) {
- router.push(response.redirect);
- }
- };
-
- return (
-
-
- );
-}
diff --git a/src/lib/actions/signIn.ts b/src/lib/actions/signIn.ts
deleted file mode 100644
index 0e34e3d..0000000
--- a/src/lib/actions/signIn.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { z } from 'zod';
-import { Argon2id } from 'oslo/password';
-import { lucia } from '@/auth';
-import { cookies } from 'next/headers';
-import { signInFormSchema } from '@/lib/form-schemas/signInFormSchema';
-import { ActionResponse } from '@/lib/types/actionResponse';
-import { URL_HOME } from '@/lib/constants';
-import prisma from '@/prisma';
-
-export default async function signIn({username, password}: z.infer): Promise {
- 'use server';
-
- const existingUser = await prisma.user.findFirst({
- where: {
- username: username.toLowerCase(),
- },
- });
- if (!existingUser) {
- return {
- type: 'error',
- message: 'Incorrect username or password',
- };
- }
-
- const validPassword = await new Argon2id().verify(existingUser.password, password);
- if (!validPassword) {
- return {
- type: 'error',
- message: 'Incorrect username or password',
- };
- }
-
- const session = await lucia.createSession(existingUser.id, {});
- const sessionCookie = lucia.createSessionCookie(session.id);
- cookies().set(sessionCookie.name, sessionCookie.value, sessionCookie.attributes);
- return {
- type: 'success',
- message: 'Signed in successfully',
- redirect: URL_HOME,
- };
-}
diff --git a/src/lib/actions/signOut.ts b/src/lib/actions/signOut.ts
deleted file mode 100644
index de58559..0000000
--- a/src/lib/actions/signOut.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { getSession, lucia } from '@/auth';
-import { cookies } from 'next/headers';
-import { ActionResponse } from '@/lib/types/actionResponse';
-import { URL_SIGN_IN } from '@/lib/constants';
-
-export default async function signOut(): Promise {
- 'use server';
-
- const session = await getSession();
- if (!session) {
- return {
- type: 'error',
- message: 'You aren\'t signed in',
- };
- }
-
- await lucia.invalidateSession(session.id);
-
- const sessionCookie = lucia.createBlankSessionCookie();
- cookies().set(sessionCookie.name, sessionCookie.value, sessionCookie.attributes);
- return {
- type: 'success',
- message: 'Signed out successfully',
- redirect: URL_SIGN_IN,
- };
-}
diff --git a/src/lib/actions/signUp.ts b/src/lib/actions/signUp.ts
deleted file mode 100644
index d7ea888..0000000
--- a/src/lib/actions/signUp.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { z } from 'zod';
-import { Argon2id } from 'oslo/password';
-import { generateId } from 'lucia';
-import { lucia } from '@/auth';
-import { cookies } from 'next/headers';
-import { signUpFormSchema } from '@/lib/form-schemas/signUpFormSchema';
-import { ActionResponse } from '@/lib/types/actionResponse';
-import { URL_HOME } from '@/lib/constants';
-import prisma from '@/prisma';
-
-export default async function signUp({username, password}: z.infer): Promise {
- 'use server';
-
- const hashedPassword = await new Argon2id().hash(password);
- const userId = generateId(15);
-
- const existingUser = await prisma.user.findFirst({
- where: {
- username: username.toLowerCase(),
- },
- });
-
- if (existingUser) {
- return {
- type: 'error',
- message: 'Username already exists',
- };
- }
-
- await prisma.user.create({
- data: {
- id: userId,
- username: username,
- password: hashedPassword,
- },
- });
-
- const session = await lucia.createSession(userId, {});
- const sessionCookie = lucia.createSessionCookie(session.id);
- cookies().set(sessionCookie.name, sessionCookie.value, sessionCookie.attributes);
- return {
- type: 'success',
- message: 'Signed up successfully',
- redirect: URL_HOME,
- };
-}
diff --git a/src/lib/form-schemas/signInFormSchema.ts b/src/lib/form-schemas/signInFormSchema.ts
deleted file mode 100644
index 0d5f458..0000000
--- a/src/lib/form-schemas/signInFormSchema.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { z } from 'zod';
-
-export const signInFormSchema = z.object({
- username: z.string().min(3).max(16),
- password: z.string().min(8).max(255),
-});
diff --git a/src/lib/form-schemas/signUpFormSchema.ts b/src/lib/form-schemas/signUpFormSchema.ts
deleted file mode 100644
index b66d6db..0000000
--- a/src/lib/form-schemas/signUpFormSchema.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { z } from 'zod';
-
-export const signUpFormSchema = z.object({
- username: z.string().min(3).max(16),
- password: z.string().min(8).max(255),
- confirm: z.string().min(8).max(255),
-}).refine(data => data.password === data.confirm, {
- message: 'Passwords do not match',
- path: ['confirm'],
-});