From b0234b737dd9c18b862fa129fd27fbca26e7d815 Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Wed, 7 Feb 2024 22:18:36 +0200 Subject: [PATCH] add guard to login page --- ui/src/app/account/account.route.ts | 5 +++++ ui/src/app/account/auth.guard.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/src/app/account/account.route.ts b/ui/src/app/account/account.route.ts index c1930b3d6..ab2235209 100644 --- a/ui/src/app/account/account.route.ts +++ b/ui/src/app/account/account.route.ts @@ -11,6 +11,11 @@ export const routes: Routes = [ { path: 'login', component: LoginComponent, + data: { + authorities: [], + pageTitle: 'global.menu.account.login.string', + }, + canActivate: [AuthGuard], }, { path: 'reset/request', diff --git a/ui/src/app/account/auth.guard.ts b/ui/src/app/account/auth.guard.ts index 67718ff98..a48d83ca3 100644 --- a/ui/src/app/account/auth.guard.ts +++ b/ui/src/app/account/auth.guard.ts @@ -20,7 +20,11 @@ export const AuthGuard = (route: ActivatedRouteSnapshot, state: RouterStateSnaps if (hasAnyAuthority) { return true } else { - router.navigate(['accessdenied']) + if (state.url === '/login') { + router.navigate(['/']) + } else { + router.navigate(['accessdenied']) + } return false } } else {