Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //abstract przed klasa: ta klasa sluzy tylko do tego aby po niej dziedziczyc
- abstract class AbstractRoleGuard {
- public abstract allowedRoleName: string; //abstract przed polem: wymaga aby dzieci mialy to pole
- public guarding():boolean {
- return this.allowedRoleName === this._getCurrentUserRoleName();
- }
- private _getCurrentUserRoleName(): string {
- return this.userService.getRoleName();
- }
- }
- //extends: odziedziczy wszystkie metody i pola, a public i protected może byc modyfikowane (do private brak dostepu)
- class AdminRoleGuard extends AbstractRoleGuard {
- public allowedRoleName: string = 'ADMIN';
- }
- class UserRoleGuard extends AbstractRoleGuard {
- public allowedRoleName: string = 'USER';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement