mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
47 lines
810 B
TypeScript
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
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
} |