Files
doneit-web/src/app/OtherService/permission.service.ts
T

46 lines
750 B
TypeScript
Raw Normal View History

2021-07-29 17:02:16 +01:00
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[] = []
2021-07-29 20:40:04 +01:00
if(!Array.isArray(args) && typeof(args) == 'string') {
2021-07-29 17:02:16 +01:00
data = [args]
2021-07-29 20:40:04 +01:00
} else {
data = args
2021-07-29 17:02:16 +01:00
}
return data.includes(this.userStore.user.Profile)
}
role(args: any) {
2021-07-29 20:40:04 +01:00
2021-07-29 17:02:16 +01:00
let UserRoleIsValid = this.userRole(args)
return {
permissionAnyOf(role) {
2021-07-29 20:40:04 +01:00
if(!Array.isArray(args) && typeof(args) == 'string') {
role = [args]
2021-07-29 17:02:16 +01:00
}
if(!UserRoleIsValid) {return false }
return true
}
}
}
}