Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2. import { Router, CanActivate } from '@angular/router';
  3.  
  4. @Injectable()
  5. export class EmployeeGuard implements CanActivate {
  6.  
  7. constructor(private router: Router) { }
  8.  
  9. canActivate() {
  10.  
  11. if(!localStorage.getItem('currentUser')) {
  12. this.router.navigate(['/login']);
  13. return false;
  14. }
  15. let role = JSON.parse(localStorage.getItem('currentUser')).role;
  16. if (!(role != 'WAITER' && role != 'CHEF' && role != 'BARTENDER' && role != 'BIDDER')) {
  17. if(JSON.parse(localStorage.getItem('currentUser')).passwordChanged == true)
  18. return true;
  19. this.router.navigate(['/change_password']);
  20. return false;
  21.  
  22. }
  23.  
  24. return true;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement