The communications platform that puts data protection first.
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.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-authorization/server/models/Permissions.js

33 lines
678 B

class ModelPermissions extends RocketChat.models._Base {
constructor() {
super(...arguments);
}
// FIND
findByRole(role, options) {
const query = {
roles: role
};
return this.find(query, options);
}
findOneById(_id) {
return this.findOne(_id);
}
createOrUpdate(name, roles) {
this.upsert({ _id: name }, { $set: { roles } });
}
addRole(permission, role) {
this.update({ _id: permission }, { $addToSet: { roles: role } });
}
removeRole(permission, role) {
this.update({ _id: permission }, { $pull: { roles: role } });
}
}
RocketChat.models.Permissions = new ModelPermissions('permissions', true);
RocketChat.models.Permissions.cache.load();