Skip to content

Commit

Permalink
add guard to login page
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Feb 7, 2024
1 parent f22f759 commit b0234b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ui/src/app/account/account.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion ui/src/app/account/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b0234b7

Please sign in to comment.