From be654fa76021d617abc60f1752f3d75094cd003d Mon Sep 17 00:00:00 2001 From: Gerald Schmittinger Date: Tue, 25 Mar 2025 21:54:37 +0100 Subject: [PATCH] fix(frontend): Problem opgelost waardoor men niet kon uitloggen wanneer het JWT Token expired was. --- frontend/src/services/auth/auth-config-loader.ts | 5 ++++- frontend/src/services/auth/auth-service.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/services/auth/auth-config-loader.ts b/frontend/src/services/auth/auth-config-loader.ts index ce8a33ca..612aa3db 100644 --- a/frontend/src/services/auth/auth-config-loader.ts +++ b/frontend/src/services/auth/auth-config-loader.ts @@ -1,11 +1,14 @@ import apiClient from "@/services/api-client.ts"; import type { FrontendAuthConfig } from "@/services/auth/auth.d.ts"; +export const AUTH_CONFIG_ENDPOINT = "auth/config"; + /** * Fetch the authentication configuration from the backend. */ export async function loadAuthConfig() { - const authConfig = (await apiClient.get("auth/config")).data; + const authConfigResponse = await apiClient.get(AUTH_CONFIG_ENDPOINT); + const authConfig = authConfigResponse.data; return { student: { authority: authConfig.student.authority, diff --git a/frontend/src/services/auth/auth-service.ts b/frontend/src/services/auth/auth-service.ts index 2b3d2807..a779c8a0 100644 --- a/frontend/src/services/auth/auth-service.ts +++ b/frontend/src/services/auth/auth-service.ts @@ -5,7 +5,7 @@ import { computed, reactive } from "vue"; import type { AuthState, Role, UserManagersForRoles } from "@/services/auth/auth.d.ts"; import { User, UserManager } from "oidc-client-ts"; -import { loadAuthConfig } from "@/services/auth/auth-config-loader.ts"; +import {AUTH_CONFIG_ENDPOINT, loadAuthConfig} from "@/services/auth/auth-config-loader.ts"; import authStorage from "./auth-storage.ts"; import { loginRoute } from "@/config.ts"; import apiClient from "@/services/api-client.ts"; @@ -108,7 +108,7 @@ async function logout(): Promise { apiClient.interceptors.request.use( async (reqConfig) => { const token = authState?.user?.access_token; - if (token) { + if (token && reqConfig.url !== AUTH_CONFIG_ENDPOINT) { reqConfig.headers.Authorization = `Bearer ${token}`; } return reqConfig;