fipamo/brain/tools/utilities/RightsManager.js

138 lines
2.4 KiB
JavaScript

export const roles = {
hnic: {
client_admin: {
create: true,
read: true,
update: true,
delete: true
},
client_user: {
create: true,
read: true,
update: true,
delete: true
},
client_project: {
create: true,
read: true,
update: true,
delete: true
},
folio_project: {
create: true,
read: true,
update: true,
delete: true
},
bookmark: {
create: true,
read: true,
update: true,
delete: true
},
post: {
create: true,
read: true,
update: true,
delete: true
},
settings: {
create: true,
read: true,
update: true,
delete: true
}
},
client: {
client_admin: {
create: false,
read: true,
update: false,
delete: false
},
client_user: {
create: true,
read: true,
update: true,
delete: true
},
client_project: {
create: true,
read: true,
update: true,
delete: false
},
folio_project: {
create: false,
read: false,
update: false,
delete: false
}
},
user: {
client_admin: {
create: false,
read: false,
update: false,
delete: false
},
client_user: {
create: false,
read: true,
update: false,
delete: false
},
client_project: {
create: false,
read: true,
update: true,
delete: false
},
folio_project: {
create: false,
read: false,
update: false,
delete: false
},
bookmark: {
create: true,
read: true,
update: true,
delete: true
},
post: {
create: false,
read: false,
update: false,
delete: false
}
}
};
export const TASK_CREATE = 'create';
export const TASK_UPDATE = 'update';
export const TASK_READ = 'read';
export const TASK_DELETE = 'delete';
export const OBJECT_CLIENT_ADMIN = 'client_admin';
export const OBJECT_CLIENT_USER = 'client_user';
export const OBJECT_PROJECT_CLIENT = 'client_project';
export const OBJECT_PROJECT_FOLIO = 'folio_project';
export const OBJECT_BOOKMARK = 'bookmark';
export const OBJECT_POST = 'post';
export const OBJECT_SETTINGS = 'settings';
export default class RightsManager {
//--------------------------
// constructor
//--------------------------
constructor() {}
//--------------------------
// methods
//--------------------------
check(role, object, task) {
//console.log(role + " *** " + object + " *** " + task);
return roles[role][object][task];
}
//--------------------------
// event handlers
//--------------------------
}