Refactor auth guard
This commit is contained in:
		
					parent
					
						
							
								fa30fc3305
							
						
					
				
			
			
				commit
				
					
						f10de66c12
					
				
			
		
					 1 changed files with 7 additions and 8 deletions
				
			
		|  | @ -2,15 +2,14 @@ import { CanActivateFn } from '@angular/router'; | |||
| import {inject} from '@angular/core'; | ||||
| import {KeycloakService} from 'keycloak-angular'; | ||||
| 
 | ||||
| export const authGuard: CanActivateFn = async (route, state) => { | ||||
| export const authGuard: CanActivateFn = async () => { | ||||
|   const keycloakService = inject(KeycloakService); | ||||
| 
 | ||||
|   const isLoggedIn = keycloakService.isLoggedIn(); | ||||
| 
 | ||||
|   if (isLoggedIn) { | ||||
|     return true; | ||||
|   } else { | ||||
|   } | ||||
| 
 | ||||
|   keycloakService.login(); | ||||
|   return false; | ||||
|   } | ||||
| }; | ||||
|  |  | |||
		Reference in a new issue