feat: login redirect opgelost
This commit is contained in:
		
							parent
							
								
									37ecad30ea
								
							
						
					
					
						commit
						49f1a98eec
					
				
					 2 changed files with 11 additions and 10 deletions
				
			
		|  | @ -109,9 +109,9 @@ const router = createRouter({ | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| router.beforeEach(async (to, from, next) => { | router.beforeEach(async (to, from, next) => { | ||||||
|     // Verify if user is logged in for paths that require authentication
 |     // Verify if user is logged in before accessing certain routes
 | ||||||
|     if (to.meta.requiresAuth) { |     if (to.meta.requiresAuth) { | ||||||
|         if (!authState.isLoggedIn) { |         if (!authState.isLoggedIn.value) { | ||||||
|             next("/login"); |             next("/login"); | ||||||
|         } else { |         } else { | ||||||
|             next(); |             next(); | ||||||
|  |  | ||||||
|  | @ -20,6 +20,15 @@ async function getUserManagers(): Promise<UserManagersForRoles> { | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * Information about the current authentication state. | ||||||
|  |  */ | ||||||
|  | const authState = reactive<AuthState>({ | ||||||
|  |     user: null, | ||||||
|  |     accessToken: null, | ||||||
|  |     activeRole: authStorage.getActiveRole() || null, | ||||||
|  | }); | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  * Load the information about who is currently logged in from the IDP. |  * Load the information about who is currently logged in from the IDP. | ||||||
|  */ |  */ | ||||||
|  | @ -35,14 +44,6 @@ async function loadUser(): Promise<User | null> { | ||||||
|     return user; |     return user; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /** |  | ||||||
|  * Information about the current authentication state. |  | ||||||
|  */ |  | ||||||
| const authState = reactive<AuthState>({ |  | ||||||
|     user: null, |  | ||||||
|     accessToken: null, |  | ||||||
|     activeRole: authStorage.getActiveRole() || null, |  | ||||||
| }); |  | ||||||
| 
 | 
 | ||||||
| const isLoggedIn = computed(() => authState.user !== null); | const isLoggedIn = computed(() => authState.user !== null); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue