import { AuthService } from './../services/auth.service' ; import { Injectable } from '@angular/core' ; import { CanActivate , ActivatedRouteSnapshot , RouterStateSnapshot , Router , Route } from '@angular/router' ; import { Observable } from 'rxjs' ; @ Injectable ( ) export class RoleGuard implements CanActivate { constructor ( private _authService , private _router ) { } canActivate ( next , state ) { const user = this . _authService . decode ( ) ; if ( user . role === next . data . role ) { return true ; } this . _router . navigate ( [ '/404' ] ) ; return false ; } }