From 8779652093836aaa0d9ad9a0eb939a9fb366b107 Mon Sep 17 00:00:00 2001 From: manuel-delvillar <68391066+manuel-delvillar@users.noreply.github.com> Date: Thu, 23 Feb 2023 13:01:23 -0600 Subject: [PATCH 1/2] Fix page cannot load on incognito mode --- ui/src/app/auth/auth-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/app/auth/auth-service.ts b/ui/src/app/auth/auth-service.ts index f850a570d..a43fcae0e 100644 --- a/ui/src/app/auth/auth-service.ts +++ b/ui/src/app/auth/auth-service.ts @@ -85,7 +85,7 @@ export class AuthService extends Whitelabelled implements IAuthService { if (ENABLE_ROLES) { const allowedRoles = ActionByRoles.get(buttonAction) ?? []; const userRoles = this.getRole()?.split(","); - return this.hasRole(allowedRoles, userRoles); + return this.hasRole(allowedRoles, userRoles ?? []); } return true; } From 1424b249979366818ebbd84b373732cf281d09d3 Mon Sep 17 00:00:00 2001 From: manuel-delvillar <68391066+manuel-delvillar@users.noreply.github.com> Date: Thu, 23 Feb 2023 13:02:14 -0600 Subject: [PATCH 2/2] Fix no roles - Now roles doesn't exit on local storage it is necessary to login again to get roles. --- ui/src/app/app.component.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts index 5f18aa7e4..06d20f6e7 100644 --- a/ui/src/app/app.component.ts +++ b/ui/src/app/app.component.ts @@ -28,6 +28,7 @@ export class AppComponent extends Whitelabelled implements OnInit { this.toastService.loaderSubject.subscribe(visible => { this.blockingLoaderVisible = visible }) + this.validateRoles() } ngOnInit(): void { @@ -75,4 +76,10 @@ export class AppComponent extends Whitelabelled implements OnInit { } } + + validateRoles(): void { + if (this.authService.getRole() === null && this.authService.currentAuthToken()) { + this.router.navigate(["/logout"]) + } + } }