1
0
mirror of https://github.com/Fayorg/calendrier-avant.git synced 2026-05-27 17:18:38 +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

@@ -30,7 +30,7 @@ export const authOptions: NextAuthOptions = {
callbacks: {
async jwt({ token, user }) {
if (user) {
token.userId = user.id;
token.userId = parseInt(user.id as string);
token.firstName = user.firstName;
token.lastName = user.lastName;
token.isTeacher = user.isTeacher;
@@ -38,10 +38,12 @@ export const authOptions: NextAuthOptions = {
return token;
},
async session({ session, token, user }) {
session.user.id = token.userId;
session.user.firstName = token.firstName;
session.user.lastName = token.lastName;
session.user.isTeacher = token.isTeacher;
if(token) {
session.user.id = token.userId;
session.user.firstName = token.firstName;
session.user.lastName = token.lastName;
session.user.isTeacher = token.isTeacher;
}
return session;
},
},