Skip to content

Commit

Permalink
Merge pull request #10 from cerberauth/nextjs-token-sub
Browse files Browse the repository at this point in the history
fix: get user id from id_token
  • Loading branch information
emmanuelgautier authored Sep 3, 2024
2 parents 42ea2ff + 9fe05dc commit 345b57c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/nextjs-app/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,26 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
type: 'oidc',
clientId: process.env.AUTH_CLIENT_ID,
clientSecret: process.env.AUTH_CLIENT_SECRET,
checks: ['pkce', 'state'],
checks: ['pkce', 'state', 'nonce'],
authorization: {
params: { scope: 'openid profile email' }
},
idToken: true,
}],
session: { strategy: 'jwt' },
callbacks: {
jwt: ({ token, profile }) => {
if (profile?.sub && profile?.email) {
return {
sub: profile.sub,
name: profile.name,
email: profile.email,
picture: profile.picture,
}
}

return token
},
session: async ({ session }) => {
return session
},
Expand Down

0 comments on commit 345b57c

Please sign in to comment.