diff --git a/src/app/core/auth/auth.guard.ts b/src/app/core/auth/auth.guard.ts index 0689e827..67e16175 100644 --- a/src/app/core/auth/auth.guard.ts +++ b/src/app/core/auth/auth.guard.ts @@ -1,5 +1,12 @@ import { inject } from '@angular/core'; -import { ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree } from '@angular/router'; +import { + ActivatedRouteSnapshot, + CanActivateFn, + GuardResult, + RedirectCommand, + Router, + RouterStateSnapshot +} from '@angular/router'; import { of } from 'rxjs'; import { map, switchMap } from 'rxjs/operators'; @@ -35,7 +42,9 @@ function toAuthGuardConfig( return {}; } -export function authGuard(configOrRoles?: string | string[] | Partial) { +export function authGuard( + configOrRoles?: string | string[] | Partial +): CanActivateFn { return (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => { // eslint-disable-next-line deprecation/deprecation const router = inject(Router); @@ -58,18 +67,18 @@ export function authGuard(configOrRoles?: string | string[] | Partial sessionService.getCurrentEua()), - map((): boolean | UrlTree => { + map((): GuardResult => { // The user still isn't authenticated if (!session().isAuthenticated()) { - return router.parseUrl('/signin'); + return new RedirectCommand(router.parseUrl('/signin')); } // Check to see if the user needs to agree to the end user agreement if (config.requiresEua && !session().isEuaCurrent()) { - return router.parseUrl('/eua'); + return new RedirectCommand(router.parseUrl('/eua')); } - if (!session().isAdmin()) { + if (!session().isAdmin() || true) { // ----------------------------------------------------------- // Check the role requirements for the route // ----------------------------------------------------------- @@ -78,7 +87,7 @@ export function authGuard(configOrRoles?: string | string[] | Partial