This commit is contained in:
Peter Maquiran
2021-09-30 15:56:04 +01:00
parent 37a233caec
commit 7364277d95
21 changed files with 36 additions and 23 deletions
@@ -0,0 +1,42 @@
import { Injectable } from '@angular/core';
import { SessionStore } from '../../store/session.service';
@Injectable({
providedIn: 'root'
})
export class PermissionService {
SessionStore = SessionStore
constructor() { }
userRole(args) {
if(!Array.isArray(args)) {
args = [args]
}
return args.includes(this.SessionStore.user.Profile)
}
role(args: any) {
let UserRoleIsValid = this.userRole(args)
return {
permissionAnyOf(role) {
if(!Array.isArray(role)) {
role = [role]
}
if(!UserRoleIsValid) {return false }
return true
}
}
}
}