metamigo: store user info in nextauth session
This commit is contained in:
parent
11c595619d
commit
cdccc7f062
2 changed files with 7 additions and 16 deletions
|
|
@ -70,20 +70,10 @@ const nextAuthOptions = (config: IAppConfig, req: NextApiRequest) => {
|
|||
providers,
|
||||
adapter,
|
||||
callbacks: {
|
||||
async jwt(token: any, user: any) {
|
||||
const isSignIn = Boolean(user);
|
||||
// Add auth_time to token on signin in
|
||||
if (isSignIn) {
|
||||
// not sure what this does
|
||||
// if (!token.aud) token.aud;
|
||||
|
||||
token.aud = nextAuth.audience;
|
||||
token.picture = user.avatar;
|
||||
token.userId = user.id;
|
||||
token.role = user.userRole ? `app_${user.userRole}` : "app_anonymous";
|
||||
}
|
||||
|
||||
return token;
|
||||
async session({session, token, user}) {
|
||||
session.user.id = user.id
|
||||
session.user.userRole = user.userRole;
|
||||
return session;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue