add: new property on session & token
This commit is contained in:
parent
2e2a44cb5d
commit
8b32c62754
|
@ -9,7 +9,8 @@ export async function authenticate(key: string) {
|
|||
id: true,
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
isTeacher: true
|
||||
isTeacher: true,
|
||||
isAdmin: true
|
||||
},
|
||||
where: {
|
||||
key: key
|
||||
|
@ -32,6 +33,7 @@ export const authOptions: NextAuthOptions = {
|
|||
token.firstName = user.firstName;
|
||||
token.lastName = user.lastName;
|
||||
token.isTeacher = user.isTeacher;
|
||||
token.isAdmin = user.isAdmin;
|
||||
}
|
||||
return token;
|
||||
},
|
||||
|
@ -41,6 +43,7 @@ export const authOptions: NextAuthOptions = {
|
|||
session.user.firstName = token.firstName;
|
||||
session.user.lastName = token.lastName;
|
||||
session.user.isTeacher = token.isTeacher;
|
||||
session.user.isAdmin = token.isAdmin;
|
||||
}
|
||||
return session;
|
||||
},
|
||||
|
|
|
@ -8,6 +8,7 @@ declare module "next-auth" {
|
|||
firstName: string;
|
||||
lastName: string
|
||||
isTeacher: boolean;
|
||||
isAdmin: boolean;
|
||||
} & DefaultSession["user"];
|
||||
}
|
||||
interface User {
|
||||
|
@ -15,6 +16,7 @@ declare module "next-auth" {
|
|||
firstName: string;
|
||||
lastName: string
|
||||
isTeacher: boolean;
|
||||
isAdmin: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,5 +26,6 @@ declare module "next-auth/jwt" {
|
|||
firstName: string;
|
||||
lastName: string
|
||||
isTeacher: boolean;
|
||||
isAdmin: boolean;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue