Skip to content

Commit

Permalink
chore(auth): return user.id (#2161)
Browse files Browse the repository at this point in the history
  • Loading branch information
thiskevinwang authored Sep 7, 2023
1 parent 96167f9 commit 0349c3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions next-auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ declare module 'next-auth' {
* Object representing an authenticated user.
*/
user: {
/** The user's HashiCorp ID */
id?: string
/** The user's nickname. */
nickname?: string | null
} & DefaultSession['user']
Expand Down
6 changes: 5 additions & 1 deletion src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ export default NextAuth({
...session,
accessToken: token.access_token,
id: token.sub,
user: { ...session.user, nickname: token.nickname },
user: {
...session.user,
nickname: token.nickname,
id: token.sub,
},
error: token.error,
}
},
Expand Down

1 comment on commit 0349c3b

@vercel
Copy link

@vercel vercel bot commented on 0349c3b Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.