feat: add sub to token

This commit is contained in:
2026-05-06 22:17:29 +02:00
parent b006b07e63
commit 1f7164ed2b
+4 -3
View File
@@ -4,9 +4,9 @@ import { JWT } from "next-auth/jwt";
declare module "next-auth" { declare module "next-auth" {
interface Session { interface Session {
accessToken?: string; accessToken: string;
idToken?: string; idToken: string;
roles?: string[]; roles: string[];
error?: string; error?: string;
} }
} }
@@ -126,6 +126,7 @@ export const authOptions: NextAuthOptions = {
token.refreshToken = account.refresh_token!; token.refreshToken = account.refresh_token!;
token.idToken = account.id_token!; token.idToken = account.id_token!;
token.accessTokenExpiresAt = account.expires_at!; token.accessTokenExpiresAt = account.expires_at!;
token.sub = decodedAccessToken.sub!
token.refreshTokenExpiresAt = decodedRefreshToken.exp ?? NEVER_EXPIRES; token.refreshTokenExpiresAt = decodedRefreshToken.exp ?? NEVER_EXPIRES;
token.roles = [ token.roles = [
...new Set([ ...new Set([