chore(auth): update NextAuth configuration to include JWT language

chore(eslint): add warning rule for unused variables in ESLint configuration
This commit is contained in:
ngc2207 2024-12-11 20:27:57 +08:00
parent b69cc453e8
commit 52a7ee5d0b
2 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,7 @@
{
"extends": ["next/core-web-vitals", "next/typescript"],
"rules": {
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-empty-object-type": "warn"
}
}

View File

@ -1,13 +1,14 @@
import NextAuth, { type DefaultSession } from "next-auth";
import NextAuth from "next-auth";
import { JWT } from "next-auth/jwt";
import Gitea, { GiteaProfile } from "@/lib/providers/gitea";
declare module "next-auth" {
interface User extends GiteaProfile {}
}
interface Session {
user: {
language: string;
} & DefaultSession["user"];
declare module "next-auth/jwt" {
interface JWT {
language?: string;
}
}
@ -30,8 +31,9 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
return token;
},
session({ session, token }) {
session.user.language = token.language as string;
session.user.language = token.language;
return session;
},
},
debug: process.env.NODE_ENV === "development",
});