Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { Router, CanActivate } from '@angular/router';
- @Injectable()
- export class EmployeeGuard implements CanActivate {
- constructor(private router: Router) { }
- canActivate() {
- if(!localStorage.getItem('currentUser')) {
- this.router.navigate(['/login']);
- return false;
- }
- let role = JSON.parse(localStorage.getItem('currentUser')).role;
- if (!(role != 'WAITER' && role != 'CHEF' && role != 'BARTENDER' && role != 'BIDDER')) {
- if(JSON.parse(localStorage.getItem('currentUser')).passwordChanged == true)
- return true;
- this.router.navigate(['/change_password']);
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement