This commit is contained in:
Peter Maquiran
2021-07-29 17:02:16 +01:00
parent 87e84c3bfe
commit 9138f9903c
6 changed files with 141 additions and 3 deletions
@@ -0,0 +1,42 @@
import { Injectable } from '@angular/core';
import { UserStore } from 'src/app/store/user.service'
@Injectable({
providedIn: 'root'
})
export class PermissionService {
userStore = UserStore
constructor() { }
userRole(args) {
let data: string[] = []
if(!Array.isArray(args) && typeof(args) == 'string') {
data = [args]
}
return data.includes(this.userStore.user.Profile)
}
role(args: any) {
let UserRoleIsValid = this.userRole(args)
return {
permissionAnyOf(role) {
if(!Array.isArray(role) && typeof(role) == 'string') {
role = [role]
}
if(!UserRoleIsValid) {return false }
return true
}
}
}
}