Skip to content

Instantly share code, notes, and snippets.

@FSou1
Created February 25, 2020 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FSou1/d648778dec46d25d7e949eb2d301a9c2 to your computer and use it in GitHub Desktop.
Save FSou1/d648778dec46d25d7e949eb2d301a9c2 to your computer and use it in GitHub Desktop.
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