You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1020 B
26 lines
1020 B
5 years ago
|
import policyClasses from '@Global/policy';
|
||
|
import { UserService } from "@Global/services/storage.services";
|
||
|
import globalStore from "@Global/store";
|
||
|
import authStore from "@Core/store";
|
||
|
|
||
|
export default (model, object, module = null) => {
|
||
|
//Access To All Place For Site Manager
|
||
|
let siteOwner = UserService.get().is_owner == "true";
|
||
|
if (siteOwner) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
let policyClass = model.split('::')[0] + 'Policy';
|
||
|
let policymethod = model.split('::')[1];
|
||
|
module = module ? module : globalStore.state.common.current_module;
|
||
|
let rootPermissions = authStore.state.auth.permissions;
|
||
|
let permissions = rootPermissions[module] ? Object.values(rootPermissions[module]) : [] ;
|
||
|
|
||
|
//instance policty class
|
||
|
let policy = new policyClasses[policyClass];
|
||
|
if (typeof policy == 'object' && typeof policy[policymethod] == 'function' ) {
|
||
|
return policy[policymethod]({module, rootPermissions, permissions}, object);
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
};
|