1
0
mirror of https://github.com/Fayorg/calendrier-avant.git synced 2026-05-27 17:18:38 +02:00

add: full authentication with NextAuth

This commit is contained in:
2023-12-18 14:59:34 +01:00
parent c48f1e23a3
commit 226100f25a
12 changed files with 273 additions and 130 deletions

View File

@@ -1,6 +1,7 @@
import Credentials from "next-auth/providers/credentials";
import prisma from "./prisma";
import { getServerSession, RequestInternal, type NextAuthOptions, User } from "next-auth";
import type { GetServerSidePropsContext, NextApiRequest, NextApiResponse } from "next"
export async function authenticate(key: string) {
console.log("Running authenticate function with key: " + key);
@@ -72,4 +73,9 @@ export const authOptions: NextAuthOptions = {
],
};
// Use it in server contexts
export function auth(...args: [GetServerSidePropsContext["req"], GetServerSidePropsContext["res"]] | [NextApiRequest, NextApiResponse] | []) {
return getServerSession(...args, authOptions)
}
export const getAuthServerSession = () => getServerSession(authOptions);