@@ -3,9 +3,10 @@ import { AppService } from '../app.service';
33import { FormBuilder , FormGroup } from '@angular/forms' ;
44import { CloudAppConfigService , CloudAppEventsService } from '@exlibris/exl-cloudapp-angular-lib' ;
55import { ToastrService } from 'ngx-toastr' ;
6- import { CanActivate , Router , ActivatedRouteSnapshot , RouterStateSnapshot } from '@angular/router' ;
6+ import { CanActivate , Router } from '@angular/router' ;
77import { Observable } from 'rxjs' ;
88import { map } from 'rxjs/operators' ;
9+ import { ErrorMessages } from '../static/error.component' ;
910
1011@Component ( {
1112 selector : 'app-configuration' ,
@@ -61,15 +62,14 @@ export class ConfigurationGuard implements CanActivate {
6162 private eventsService : CloudAppEventsService ,
6263 private router : Router
6364 ) { }
64- canActivate (
65- next : ActivatedRouteSnapshot ,
66- state : RouterStateSnapshot ) : Observable < boolean > {
67- return this . eventsService . getInitData ( ) . pipe ( map ( data => {
68- if ( ! data . user . isAdmin ) {
69- this . router . navigate ( [ '/' ] ) ;
70- return false ;
71- }
72- return true ;
73- } ) )
65+ canActivate ( ) : Observable < boolean > {
66+ return this . eventsService . getInitData ( ) . pipe ( map ( data => {
67+ if ( ! data . user . isAdmin ) {
68+ this . router . navigate ( [ '/error' ] ,
69+ { queryParams : { error : ErrorMessages . NO_ACCESS } } ) ;
70+ return false ;
71+ }
72+ return true ;
73+ } ) )
7474 }
75- }
75+ }
0 commit comments