Skip to content

Commit

Permalink
try again 👌
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustChew committed Nov 4, 2023
1 parent ba89d20 commit b130196
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,29 @@ const handler = NextAuth({

if (account) {
token.id = user.id,
token.name = user.name_zh,
token.name_zh = user.name_zh,
token.name_en = user.name_en,
token.inschool = user.inschool,
token.email = user.email
}
return token
}
},
async session({ session, token }) {
session.user = {
...session.user,
//@ts-ignore
id: token.id,
//@ts-ignore
name_zh: token.name_zh,
//@ts-ignore
name_en: token.name_en,
//@ts-ignore
inschool: token.inschool,
//@ts-ignore
email: token.email
}
return session;
},
}
})

Expand Down
8 changes: 8 additions & 0 deletions src/types/next-auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import NextAuth, { DefaultSession } from "next-auth"
import { DefaultJWT } from "next-auth/jwt"

declare module "next-auth" {
interface User {
Expand All @@ -8,6 +9,13 @@ declare module "next-auth" {
name_en: string,
email: string
}
interface JWT extends DefaultJWT {
id: string,
inschool: boolean,
name_zh: string,
name_en: string,
email: string
}
interface Session {
user: {
id: string,
Expand Down

0 comments on commit b130196

Please sign in to comment.