TSK-1848: Fixed a bug where the UI would freeze with insufficient user permissions (#1903)
This commit is contained in:
parent
3d986541b7
commit
cdc5e9404c
|
@ -45,6 +45,7 @@ const appRoutes: Routes = [
|
|||
loadChildren: () => import('./settings/settings.module').then((m) => m.SettingsModule)
|
||||
},
|
||||
{
|
||||
canActivate: [BusinessAdminGuard],
|
||||
path: '**',
|
||||
redirectTo: 'administration/workbaskets'
|
||||
}
|
||||
|
@ -55,10 +56,12 @@ const appRoutes: Routes = [
|
|||
component: NoAccessComponent
|
||||
},
|
||||
{
|
||||
canActivate: [BusinessAdminGuard],
|
||||
path: '**',
|
||||
redirectTo: 'taskana/administration/workbaskets'
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(appRoutes, { useHash: true })],
|
||||
exports: [RouterModule]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { CanActivate, Router } from '@angular/router';
|
||||
import { CanActivate, Router, UrlTree } from '@angular/router';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
||||
|
||||
|
@ -8,15 +8,11 @@ export class BusinessAdminGuard implements CanActivate {
|
|||
|
||||
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
||||
|
||||
canActivate() {
|
||||
canActivate(): boolean | UrlTree {
|
||||
if (this.taskanaEngineService.hasRole(BusinessAdminGuard.roles)) {
|
||||
return true;
|
||||
}
|
||||
return this.navigateToWorkplace();
|
||||
}
|
||||
|
||||
navigateToWorkplace(): boolean {
|
||||
this.router.navigate(['workplace']);
|
||||
return false;
|
||||
return this.router.parseUrl('/taskana/workplace');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
@ -10,25 +10,17 @@ import { catchError, map } from 'rxjs/operators';
|
|||
export class HistoryGuard implements CanActivate {
|
||||
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
||||
|
||||
canActivate(
|
||||
next: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): Observable<boolean> | Promise<boolean> | boolean {
|
||||
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> {
|
||||
return this.taskanaEngineService.isHistoryProviderEnabled().pipe(
|
||||
map((value) => {
|
||||
if (value) {
|
||||
return value;
|
||||
}
|
||||
return this.navigateToWorkplace();
|
||||
return this.router.parseUrl('/taskana/workplace');
|
||||
}),
|
||||
catchError(() => {
|
||||
return of(this.navigateToWorkplace());
|
||||
return of(this.router.parseUrl('/taskana/workplace'));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
navigateToWorkplace(): boolean {
|
||||
this.router.navigate(['workplace']);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
import { CanActivate, Router } from '@angular/router';
|
||||
import { CanActivate, Router, UrlTree } from '@angular/router';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
||||
|
||||
@Injectable()
|
||||
export class MonitorGuard implements CanActivate {
|
||||
static roles = ['ADMIN', 'MONITOR'];
|
||||
|
||||
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
||||
|
||||
canActivate() {
|
||||
canActivate(): boolean | UrlTree {
|
||||
if (this.taskanaEngineService.hasRole(MonitorGuard.roles)) {
|
||||
return true;
|
||||
}
|
||||
return this.navigateToWorkplace();
|
||||
}
|
||||
|
||||
navigateToWorkplace(): boolean {
|
||||
this.router.navigate(['workplace']);
|
||||
return false;
|
||||
return this.router.parseUrl('/taskana/workplace');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { TaskanaEngineService } from '../services/taskana-engine/taskana-engine.service';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
@ -10,25 +10,17 @@ import { catchError, map } from 'rxjs/operators';
|
|||
export class TaskRoutingGuard implements CanActivate {
|
||||
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
||||
|
||||
canActivate(
|
||||
next: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): Observable<boolean> | Promise<boolean> | boolean {
|
||||
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> {
|
||||
return this.taskanaEngineService.isCustomRoutingRulesEnabled().pipe(
|
||||
map((value) => {
|
||||
if (value) {
|
||||
return value;
|
||||
}
|
||||
return this.navigateToWorkplace();
|
||||
return this.router.parseUrl('/taskana/workplace');
|
||||
}),
|
||||
catchError(() => {
|
||||
return of(this.navigateToWorkplace());
|
||||
return of(this.router.parseUrl('/taskana/workplace'));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
navigateToWorkplace(): boolean {
|
||||
this.router.navigate(['workplace']);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
import { CanActivate, Router } from '@angular/router';
|
||||
import { CanActivate, Router, UrlTree } from '@angular/router';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
||||
|
||||
@Injectable()
|
||||
export class UserGuard implements CanActivate {
|
||||
static roles = ['ADMIN', 'USER'];
|
||||
|
||||
constructor(private taskanaEngineService: TaskanaEngineService, private router: Router) {}
|
||||
canActivate() {
|
||||
|
||||
canActivate(): boolean | UrlTree {
|
||||
if (this.taskanaEngineService.hasRole(UserGuard.roles)) {
|
||||
return true;
|
||||
}
|
||||
return this.navigateToNoRole();
|
||||
}
|
||||
|
||||
navigateToNoRole(): boolean {
|
||||
this.router.navigate(['no-role']);
|
||||
return false;
|
||||
return this.router.parseUrl('/taskana/no-role');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue