Files
doneit-web/src/app/OtherService/permission.service.ts
T
2021-07-29 20:40:04 +01:00

47 lines
810 B
TypeScript

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]
} else {
data = args
}
console.log('==!!==',data, this.userStore.user.Profile)
return data.includes(this.userStore.user.Profile)
}
role(args: any) {
let UserRoleIsValid = this.userRole(args)
return {
permissionAnyOf(role) {
if(!Array.isArray(args) && typeof(args) == 'string') {
role = [args]
}
if(!UserRoleIsValid) {return false }
return true
}
}
}
}