Created
February 25, 2020 03:19
-
-
Save FSou1/d648778dec46d25d7e949eb2d301a9c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { User } from '../models/user'; | |
import { Role } from '../models/role'; | |
@Injectable() | |
export class AuthService { | |
private user: User; | |
isAuthorized() { | |
return !!this.user; | |
} | |
hasRole(role: Role) { | |
return this.isAuthorized() && this.user.Role === role; | |
} | |
login(role: Role) { | |
this.user = { role: role }; | |
} | |
logout() { | |
this.user = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment