refactor(frontend): Verwijder console logs
This commit is contained in:
parent
b71dac512f
commit
293c51bab3
5 changed files with 11 additions and 10 deletions
|
@ -32,7 +32,6 @@
|
|||
function changeLanguage(langCode: string): void {
|
||||
locale.value = langCode;
|
||||
localStorage.setItem("user-lang", langCode);
|
||||
console.log(langCode);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import apiClient from "@/services/api-client.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.
|
||||
|
|
|
@ -80,15 +80,14 @@ async function handleLoginCallback(): Promise<void> {
|
|||
async function renewToken(): Promise<User | null> {
|
||||
const activeRole = authStorage.getActiveRole();
|
||||
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();
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return await (await getUserManagers())[activeRole].signinSilent();
|
||||
} catch (error) {
|
||||
console.log("Can't renew the token:");
|
||||
console.log(error);
|
||||
} catch (_error) {
|
||||
// FIXME console.log("Can't renew the token: " + error);
|
||||
await initiateLogin();
|
||||
}
|
||||
return null;
|
||||
|
@ -123,7 +122,7 @@ apiClient.interceptors.response.use(
|
|||
async (error: AxiosError<{ message?: string }>) => {
|
||||
if (error.response?.status === 401) {
|
||||
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();
|
||||
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.
|
||||
|
|
5
frontend/src/services/auth/auth.d.ts
vendored
5
frontend/src/services/auth/auth.d.ts
vendored
|
@ -19,4 +19,7 @@ export interface FrontendIdpConfig {
|
|||
}
|
||||
|
||||
export type Role = "student" | "teacher";
|
||||
export interface UserManagersForRoles { student: UserManager; teacher: UserManager }
|
||||
export interface UserManagersForRoles {
|
||||
student: UserManager;
|
||||
teacher: UserManager;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
try {
|
||||
await auth.handleLoginCallback();
|
||||
await router.replace("/"); // Redirect to home (or dashboard)
|
||||
} catch (error) {
|
||||
console.error("OIDC callback error:", error);
|
||||
} catch (_error) {
|
||||
// FIXME console.error("OIDC callback error:", error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue