fix(nextauth): eslint errors
This commit is contained in:
parent
60d455c938
commit
e54c69f216
1 changed files with 6 additions and 9 deletions
|
|
@ -6,9 +6,7 @@ import {
|
||||||
type DefaultSession,
|
type DefaultSession,
|
||||||
} from "next-auth";
|
} from "next-auth";
|
||||||
import KeycloakProvider from "next-auth/providers/keycloak";
|
import KeycloakProvider from "next-auth/providers/keycloak";
|
||||||
import { type KeycloakProfile } from "next-auth/providers/keycloak";
|
|
||||||
import { type JWT } from "next-auth/jwt";
|
import { type JWT } from "next-auth/jwt";
|
||||||
import { type OAuthConfig } from "next-auth/providers";
|
|
||||||
import { env } from "~/env.mjs";
|
import { env } from "~/env.mjs";
|
||||||
import { prisma } from "~/server/db";
|
import { prisma } from "~/server/db";
|
||||||
|
|
||||||
|
|
@ -66,10 +64,10 @@ export const authOptions: NextAuthOptions = {
|
||||||
*
|
*
|
||||||
* @see https://stackoverflow.com/a/75526977
|
* @see https://stackoverflow.com/a/75526977
|
||||||
*/
|
*/
|
||||||
async jwt({ token, account }) {
|
jwt({ token, account }) {
|
||||||
if (account) {
|
if (account) {
|
||||||
token.id_token = account.id_token
|
token.id_token = account?.id_token
|
||||||
token.provider = account.provider
|
token.provider = account?.provider
|
||||||
}
|
}
|
||||||
return token
|
return token
|
||||||
},
|
},
|
||||||
|
|
@ -104,10 +102,9 @@ export const authOptions: NextAuthOptions = {
|
||||||
*/
|
*/
|
||||||
async signOut({ token }: { token: JWT }) {
|
async signOut({ token }: { token: JWT }) {
|
||||||
if (token.provider === "keycloak") {
|
if (token.provider === "keycloak") {
|
||||||
const issuerUrl = (authOptions.providers.find(p => p.id === "keycloak") as OAuthConfig<KeycloakProfile>).options!.issuer!
|
const logOutURL = new URL(`${env.KEYCLOAK_ISSUER}/protocol/openid-connect/logout`)
|
||||||
const logOutUrl = new URL(`${issuerUrl}/protocol/openid-connect/logout`)
|
logOutURL.searchParams.set("id_token_hint", token.id_token ?? '')
|
||||||
logOutUrl.searchParams.set("id_token_hint", token.id_token!)
|
await fetch(logOutURL);
|
||||||
await fetch(logOutUrl);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue