fix(frontend): Problem opgelost waardoor men niet kon uitloggen wanneer het JWT Token expired was.
This commit is contained in:
parent
a2248de290
commit
be654fa760
2 changed files with 6 additions and 3 deletions
|
@ -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<FrontendAuthConfig>("auth/config")).data;
|
||||
const authConfigResponse = await apiClient.get<FrontendAuthConfig>(AUTH_CONFIG_ENDPOINT);
|
||||
const authConfig = authConfigResponse.data;
|
||||
return {
|
||||
student: {
|
||||
authority: authConfig.student.authority,
|
||||
|
|
|
@ -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<void> {
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue