Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public isAuthenticated(): boolean {
  2.   if (localStorage.getItem('token')){
  3.     return true;
  4.   }
  5.   else {
  6.     return false;
  7.   }
  8. }
  9.  
  10. public isAdmin(): boolean {
  11.   if (!this.isAuthenticated()) {
  12.     return false;
  13.   }
  14.   var userInfo: UserInfo = JSON.parse(localStorage.getItem('userInfo'));
  15.   if (userInfo == null) {
  16.     return false;
  17.   }
  18.   let userRole = userInfo.UserRole;
  19.   if (userRole == 1) {
  20.     return true;
  21.   }
  22.   return false;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement