diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts
new file mode 100644
index 0000000..4ac2005
--- /dev/null
+++ b/app/api/auth/[...nextauth]/route.ts
@@ -0,0 +1,6 @@
+import NextAuth from "next-auth";
+
+import { authOptions } from "@lib/authenticate";
+
+const handler = NextAuth(authOptions);
+export { handler as GET, handler as POST };
\ No newline at end of file
diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx
index 7cf6c54..1ea4753 100644
--- a/app/dashboard/page.tsx
+++ b/app/dashboard/page.tsx
@@ -1,5 +1,6 @@
import prisma from '@/lib/prisma';
import ActiveCard from './ActiveCard';
+import { getAuthServerSession } from '@/lib/authenticate';
export default async function Dashboard() {
const tests = await prisma.test.findMany({ select: { isActive: true, isPassed: true, id: true, testOf: { select: { id: true, firstName: true, lastName: true, isTeacher: true } } } });
@@ -7,6 +8,10 @@ export default async function Dashboard() {
const activeTests = tests.filter((test) => test.isActive);
const passedTests = tests.filter((test) => test.isPassed);
+ const authSession = await getAuthServerSession();
+
+ console.log(authSession);
+
return (
Dashboard
diff --git a/app/page.tsx b/app/page.tsx
index f0bd99a..3949590 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -1,14 +1,15 @@
'use client';
-import { Poppins } from 'next/font/google'
-import { Check } from 'lucide-react'
+import { Poppins } from 'next/font/google';
+import { Check } from 'lucide-react';
import { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import logo from '../images/logo.svg';
-import Image from "next/image";
-import {Input} from "@components/ui/input";
-import {white} from "next/dist/lib/picocolors";
+import Image from 'next/image';
+import { Input } from '@components/ui/input';
+import { white } from 'next/dist/lib/picocolors';
+import { signIn } from 'next-auth/react';
export default function Home() {
const [password, setPassword] = useState('');
@@ -20,21 +21,27 @@ export default function Home() {
}
}, [router]);
- function handleSubmit(event: React.FormEvent
) {
+ async function handleSubmit(event: React.FormEvent) {
event.preventDefault();
- localStorage.setItem('@password', password);
- router.push('/play');
+ // localStorage.setItem('@password', password);
+ // router.push('/play');
+
+ console.log('Trying to sign in');
+ const result = await signIn('credentials', {
+ key: password,
+ callbackUrl: '/play',
+ });
}
return (
-