diff --git a/.env.sample b/.env.sample index 2ca5830..386c603 100644 --- a/.env.sample +++ b/.env.sample @@ -29,5 +29,5 @@ POSTGRES_PASSWORD= # Keycloak NEXT_PUBLIC_KEYCLOAK_ENABLED= KEYCLOAK_ISSUER= -KEYCLOAK_CLIENT= +KEYCLOAK_CLIENT_ID= KEYCLOAK_CLIENT_SECRET= diff --git a/lib/api/controllers/users/userId/deleteUserById.ts b/lib/api/controllers/users/userId/deleteUserById.ts index 19090b5..91c507c 100644 --- a/lib/api/controllers/users/userId/deleteUserById.ts +++ b/lib/api/controllers/users/userId/deleteUserById.ts @@ -22,7 +22,10 @@ export default async function deleteUserById( } // Then, we check if the provided password matches the one stored in the database - const isPasswordValid = bcrypt.compareSync(body.password, user.password || ""); + const isPasswordValid = bcrypt.compareSync( + body.password, + user.password || "" + ); if (!isPasswordValid) { return { diff --git a/pages/api/v1/auth/[...nextauth].ts b/pages/api/v1/auth/[...nextauth].ts index 46976a5..4b5dd59 100644 --- a/pages/api/v1/auth/[...nextauth].ts +++ b/pages/api/v1/auth/[...nextauth].ts @@ -9,13 +9,12 @@ import { Adapter } from "next-auth/adapters"; import sendVerificationRequest from "@/lib/api/sendVerificationRequest"; import { Provider } from "next-auth/providers"; import verifySubscription from "@/lib/api/verifySubscription"; -import KeycloakProvider from 'next-auth/providers/keycloak'; +import KeycloakProvider from "next-auth/providers/keycloak"; const emailEnabled = process.env.EMAIL_FROM && process.env.EMAIL_SERVER ? true : false; -const keycloakEnabled = - !!process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED; +const keycloakEnabled = process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED === "true"; const adapter = PrismaAdapter(prisma); @@ -81,8 +80,8 @@ if (emailEnabled) { if (keycloakEnabled) { providers.push( KeycloakProvider({ - id: 'keycloak', - name: 'Keycloak', + id: "keycloak", + name: "Keycloak", clientId: process.env.KEYCLOAK_CLIENT_ID!, clientSecret: process.env.KEYCLOAK_CLIENT_SECRET!, issuer: process.env.KEYCLOAK_ISSUER, @@ -95,11 +94,11 @@ if (keycloakEnabled) { image: profile.picture, }; }, - }), + }) ); const _linkAccount = adapter.linkAccount; adapter.linkAccount = (account) => { - const { 'not-before-policy': _, refresh_expires_in, ...data } = account; + const { "not-before-policy": _, refresh_expires_in, ...data } = account; return _linkAccount ? _linkAccount(data) : undefined; }; } @@ -118,7 +117,8 @@ export const authOptions: AuthOptions = { callbacks: { async jwt({ token, trigger, user }) { token.sub = token.sub ? Number(token.sub) : undefined; - if (trigger === "signIn" || trigger === "signUp") token.id = user?.id as number; + if (trigger === "signIn" || trigger === "signUp") + token.id = user?.id as number; return token; },