refactor(frontend): Verwijder console logs

This commit is contained in:
Tibo De Peuter 2025-03-23 12:32:41 +01:00
parent b71dac512f
commit 293c51bab3
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
5 changed files with 11 additions and 10 deletions

View file

@ -32,7 +32,6 @@
function changeLanguage(langCode: string): void { function changeLanguage(langCode: string): void {
locale.value = langCode; locale.value = langCode;
localStorage.setItem("user-lang", langCode); localStorage.setItem("user-lang", langCode);
console.log(langCode);
} }
</script> </script>

View file

@ -1,6 +1,6 @@
import apiClient from "@/services/api-client.ts"; import apiClient from "@/services/api-client.ts";
import type { FrontendAuthConfig } from "@/services/auth/auth.d.ts"; import type { FrontendAuthConfig } from "@/services/auth/auth.d.ts";
import type {UserManagerSettings} from "oidc-client-ts"; import type { UserManagerSettings } from "oidc-client-ts";
/** /**
* Fetch the authentication configuration from the backend. * Fetch the authentication configuration from the backend.

View file

@ -80,15 +80,14 @@ async function handleLoginCallback(): Promise<void> {
async function renewToken(): Promise<User | null> { async function renewToken(): Promise<User | null> {
const activeRole = authStorage.getActiveRole(); const activeRole = authStorage.getActiveRole();
if (!activeRole) { if (!activeRole) {
console.log("Can't renew the token: Not logged in!"); // FIXME console.log("Can't renew the token: Not logged in!");
await initiateLogin(); await initiateLogin();
return null; return null;
} }
try { try {
return await (await getUserManagers())[activeRole].signinSilent(); return await (await getUserManagers())[activeRole].signinSilent();
} catch (error) { } catch (_error) {
console.log("Can't renew the token:"); // FIXME console.log("Can't renew the token: " + error);
console.log(error);
await initiateLogin(); await initiateLogin();
} }
return null; return null;
@ -123,7 +122,7 @@ apiClient.interceptors.response.use(
async (error: AxiosError<{ message?: string }>) => { async (error: AxiosError<{ message?: string }>) => {
if (error.response?.status === 401) { if (error.response?.status === 401) {
if (error.response.data.message === "token_expired") { if (error.response.data.message === "token_expired") {
console.log("Access token expired, trying to refresh..."); // FIXME console.log("Access token expired, trying to refresh...");
await renewToken(); await renewToken();
return apiClient(error.config!); // Retry the request return apiClient(error.config!); // Retry the request
} // Apparently, the user got a 401 because he was not logged in yet at all. Redirect him to login. } // Apparently, the user got a 401 because he was not logged in yet at all. Redirect him to login.

View file

@ -19,4 +19,7 @@ export interface FrontendIdpConfig {
} }
export type Role = "student" | "teacher"; export type Role = "student" | "teacher";
export interface UserManagersForRoles { student: UserManager; teacher: UserManager } export interface UserManagersForRoles {
student: UserManager;
teacher: UserManager;
}

View file

@ -9,8 +9,8 @@
try { try {
await auth.handleLoginCallback(); await auth.handleLoginCallback();
await router.replace("/"); // Redirect to home (or dashboard) await router.replace("/"); // Redirect to home (or dashboard)
} catch (error) { } catch (_error) {
console.error("OIDC callback error:", error); // FIXME console.error("OIDC callback error:", error);
} }
}); });
</script> </script>