Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //abstract przed klasa: ta klasa sluzy tylko do tego aby po niej dziedziczyc
  2. abstract class AbstractRoleGuard {
  3.     public abstract allowedRoleName: string; //abstract przed polem: wymaga aby dzieci mialy to pole
  4.     public guarding():boolean {
  5.         return this.allowedRoleName === this._getCurrentUserRoleName();
  6.     }
  7.     private _getCurrentUserRoleName(): string {
  8.       return this.userService.getRoleName();
  9.     }
  10. }
  11.  //extends: odziedziczy wszystkie metody i pola, a public i protected może byc modyfikowane (do private brak dostepu)
  12. class AdminRoleGuard extends AbstractRoleGuard {
  13.     public allowedRoleName: string = 'ADMIN';
  14. }
  15.  
  16. class UserRoleGuard extends AbstractRoleGuard {
  17.     public allowedRoleName: string = 'USER';
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement