Hide UI tour steps if user doesnt have permissions

This commit is contained in:
shamoon
2023-04-09 16:36:05 -07:00
parent c3d706bc22
commit 1017e48c9e
2 changed files with 16 additions and 4 deletions

View File

@@ -8,13 +8,15 @@ import {
import { Injectable } from '@angular/core'
import { PermissionsService } from '../services/permissions.service'
import { ToastService } from '../services/toast.service'
import { TourService } from 'ngx-ui-tour-ng-bootstrap'
@Injectable()
export class PermissionsGuard implements CanActivate {
constructor(
private permissionsService: PermissionsService,
private router: Router,
private toastService: ToastService
private toastService: ToastService,
private tourService: TourService
) {}
canActivate(
@@ -27,9 +29,12 @@ export class PermissionsGuard implements CanActivate {
route.data.requiredPermission.type
)
) {
this.toastService.showError(
$localize`You don't have permissions to do that`
)
// Check if tour is running 1 = TourState.ON
if (this.tourService.getStatus() !== 1) {
this.toastService.showError(
$localize`You don't have permissions to do that`
)
}
return this.router.parseUrl('/dashboard')
} else {
return true