Skip to content

Commit

Permalink
JWTコールバックにユーザーIDを追加し、セッションにユーザーIDを設定しました (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttizze authored Feb 23, 2025
2 parents 7d81bca + 90b944d commit 06b3383
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions next/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
callbacks: {
async jwt({ token, user }) {
if (user) {
token.id = user.id;
token.handle = user.handle;
token.profile = user.profile;
token.createdAt = user.createdAt;
Expand All @@ -29,6 +30,7 @@ export const { handlers, auth, signIn, signOut } = NextAuth({
return token;
},
async session({ session, token }) {
session.user.id = token.id as string;
session.user.handle = token.handle as string;
session.user.profile = token.profile as string;
session.user.createdAt = token.createdAt as Date;
Expand Down

0 comments on commit 06b3383

Please sign in to comment.