1
0
mirror of https://github.com/Fayorg/calendrier-avant.git synced 2026-05-28 01:28:37 +02:00

add: authentication WIP

This commit is contained in:
2023-12-18 10:01:22 +01:00
parent 2eaccd52e4
commit c48f1e23a3
5 changed files with 52 additions and 48 deletions

View File

@@ -1,17 +1,19 @@
import prisma from '@/lib/prisma';
import ActiveCard from './ActiveCard';
import { getAuthServerSession } from '@/lib/authenticate';
import { red } from 'next/dist/lib/picocolors';
import { redirect } from 'next/navigation';
export default async function Dashboard() {
const authSession = await getAuthServerSession();
console.log(authSession);
if (!authSession || !authSession.user.isTeacher) return redirect('/');
const tests = await prisma.test.findMany({ select: { isActive: true, isPassed: true, id: true, testOf: { select: { id: true, firstName: true, lastName: true, isTeacher: true } } } });
const activeTests = tests.filter((test) => test.isActive);
const passedTests = tests.filter((test) => test.isPassed);
const authSession = await getAuthServerSession();
console.log(authSession);
return (
<div>
<h1>Dashboard</h1>