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 { |     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> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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. | ||||||
|  |  | ||||||
|  | @ -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.
 | ||||||
|  |  | ||||||
							
								
								
									
										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 type Role = "student" | "teacher"; | ||||||
| export interface UserManagersForRoles { student: UserManager; teacher: UserManager } | export interface UserManagersForRoles { | ||||||
|  |     student: UserManager; | ||||||
|  |     teacher: UserManager; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -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> | ||||||
|  |  | ||||||
		Reference in a new issue