From 52a7ee5d0b42b85f8d278a502caa94fc3a2e1e2f Mon Sep 17 00:00:00 2001 From: ngc2207 Date: Wed, 11 Dec 2024 20:27:57 +0800 Subject: [PATCH] chore(auth): update NextAuth configuration to include JWT language chore(eslint): add warning rule for unused variables in ESLint configuration --- .eslintrc.json | 1 + src/auth.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index e878823..319342c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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" } } diff --git a/src/auth.ts b/src/auth.ts index 8fef9af..774e61c 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -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", });