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)
|
loadChildren: () => import('./settings/settings.module').then((m) => m.SettingsModule)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
canActivate: [BusinessAdminGuard],
|
||||||
path: '**',
|
path: '**',
|
||||||
redirectTo: 'administration/workbaskets'
|
redirectTo: 'administration/workbaskets'
|
||||||
}
|
}
|
||||||
|
@ -55,10 +56,12 @@ const appRoutes: Routes = [
|
||||||
component: NoAccessComponent
|
component: NoAccessComponent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
canActivate: [BusinessAdminGuard],
|
||||||
path: '**',
|
path: '**',
|
||||||
redirectTo: 'taskana/administration/workbaskets'
|
redirectTo: 'taskana/administration/workbaskets'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [RouterModule.forRoot(appRoutes, { useHash: true })],
|
imports: [RouterModule.forRoot(appRoutes, { useHash: true })],
|
||||||
exports: [RouterModule]
|
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 { Injectable } from '@angular/core';
|
||||||
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
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) {}
|
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
||||||
|
|
||||||
canActivate() {
|
canActivate(): boolean | UrlTree {
|
||||||
if (this.taskanaEngineService.hasRole(BusinessAdminGuard.roles)) {
|
if (this.taskanaEngineService.hasRole(BusinessAdminGuard.roles)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return this.navigateToWorkplace();
|
|
||||||
}
|
|
||||||
|
|
||||||
navigateToWorkplace(): boolean {
|
return this.router.parseUrl('/taskana/workplace');
|
||||||
this.router.navigate(['workplace']);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Injectable } from '@angular/core';
|
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 { Observable, of } from 'rxjs';
|
||||||
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
|
@ -10,25 +10,17 @@ import { catchError, map } from 'rxjs/operators';
|
||||||
export class HistoryGuard implements CanActivate {
|
export class HistoryGuard implements CanActivate {
|
||||||
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
||||||
|
|
||||||
canActivate(
|
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> {
|
||||||
next: ActivatedRouteSnapshot,
|
|
||||||
state: RouterStateSnapshot
|
|
||||||
): Observable<boolean> | Promise<boolean> | boolean {
|
|
||||||
return this.taskanaEngineService.isHistoryProviderEnabled().pipe(
|
return this.taskanaEngineService.isHistoryProviderEnabled().pipe(
|
||||||
map((value) => {
|
map((value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return this.navigateToWorkplace();
|
return this.router.parseUrl('/taskana/workplace');
|
||||||
}),
|
}),
|
||||||
catchError(() => {
|
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 { Injectable } from '@angular/core';
|
||||||
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MonitorGuard implements CanActivate {
|
export class MonitorGuard implements CanActivate {
|
||||||
static roles = ['ADMIN', 'MONITOR'];
|
static roles = ['ADMIN', 'MONITOR'];
|
||||||
|
|
||||||
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
||||||
|
|
||||||
canActivate() {
|
canActivate(): boolean | UrlTree {
|
||||||
if (this.taskanaEngineService.hasRole(MonitorGuard.roles)) {
|
if (this.taskanaEngineService.hasRole(MonitorGuard.roles)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return this.navigateToWorkplace();
|
|
||||||
}
|
|
||||||
|
|
||||||
navigateToWorkplace(): boolean {
|
return this.router.parseUrl('/taskana/workplace');
|
||||||
this.router.navigate(['workplace']);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Injectable } from '@angular/core';
|
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 { Observable, of } from 'rxjs';
|
||||||
import { TaskanaEngineService } from '../services/taskana-engine/taskana-engine.service';
|
import { TaskanaEngineService } from '../services/taskana-engine/taskana-engine.service';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
|
@ -10,25 +10,17 @@ import { catchError, map } from 'rxjs/operators';
|
||||||
export class TaskRoutingGuard implements CanActivate {
|
export class TaskRoutingGuard implements CanActivate {
|
||||||
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) {}
|
||||||
|
|
||||||
canActivate(
|
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> {
|
||||||
next: ActivatedRouteSnapshot,
|
|
||||||
state: RouterStateSnapshot
|
|
||||||
): Observable<boolean> | Promise<boolean> | boolean {
|
|
||||||
return this.taskanaEngineService.isCustomRoutingRulesEnabled().pipe(
|
return this.taskanaEngineService.isCustomRoutingRulesEnabled().pipe(
|
||||||
map((value) => {
|
map((value) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return this.navigateToWorkplace();
|
return this.router.parseUrl('/taskana/workplace');
|
||||||
}),
|
}),
|
||||||
catchError(() => {
|
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 { Injectable } from '@angular/core';
|
||||||
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
import { TaskanaEngineService } from 'app/shared/services/taskana-engine/taskana-engine.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserGuard implements CanActivate {
|
export class UserGuard implements CanActivate {
|
||||||
static roles = ['ADMIN', 'USER'];
|
static roles = ['ADMIN', 'USER'];
|
||||||
|
|
||||||
constructor(private taskanaEngineService: TaskanaEngineService, private router: Router) {}
|
constructor(private taskanaEngineService: TaskanaEngineService, private router: Router) {}
|
||||||
canActivate() {
|
|
||||||
|
canActivate(): boolean | UrlTree {
|
||||||
if (this.taskanaEngineService.hasRole(UserGuard.roles)) {
|
if (this.taskanaEngineService.hasRole(UserGuard.roles)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return this.navigateToNoRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
navigateToNoRole(): boolean {
|
return this.router.parseUrl('/taskana/no-role');
|
||||||
this.router.navigate(['no-role']);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue