Merge branch 'feature/auth-troubleshooting' into develop
This commit is contained in:
@@ -35,8 +35,12 @@ export const authConfig: NextAuthConfig = {
|
|||||||
// see: https://stackoverflow.com/questions/70409219/get-user-id-from-session-in-next-auth-client
|
// see: https://stackoverflow.com/questions/70409219/get-user-id-from-session-in-next-auth-client
|
||||||
jwt({ token, account, user }) {
|
jwt({ token, account, user }) {
|
||||||
if (account) {
|
if (account) {
|
||||||
token.accessToken = account.access_token
|
// console.log("(jwt) account:", account);
|
||||||
token.id = user?.id
|
// console.log("(jwt) user:", user);
|
||||||
|
token.accessToken = account.access_token;
|
||||||
|
// attach Google account ID to the token
|
||||||
|
token.piggyback_providerAccountId = account.providerAccountId;
|
||||||
|
|
||||||
}
|
}
|
||||||
return token
|
return token
|
||||||
},
|
},
|
||||||
@@ -45,7 +49,9 @@ export const authConfig: NextAuthConfig = {
|
|||||||
// see: https://stackoverflow.com/questions/70409219/get-user-id-from-session-in-next-auth-client
|
// see: https://stackoverflow.com/questions/70409219/get-user-id-from-session-in-next-auth-client
|
||||||
async session({ session, token }:{ session:Session, token:any }) {
|
async session({ session, token }:{ session:Session, token:any }) {
|
||||||
if(session.user && token) {
|
if(session.user && token) {
|
||||||
session.user.id = token.id;
|
// assign Google account ID from the token to the Session user ID
|
||||||
|
session.user.id = token.piggyback_providerAccountId;
|
||||||
|
// console.log("(jwt) token:", token);
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user