mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
improve
This commit is contained in:
@@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user