mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
8c1a0b8d0c
- Apps are marked as removed in 3.0, never officially launched and have been deprecated for at least 2 years. - We've slowly removed bits that got in our way or were insecure over time meaning they mostly didn't work - This cleans up the remainder of the logic - The tables should be cleaned up in a future major
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
const ghostBookshelf = require('./base');
|
|
|
|
let Permission,
|
|
Permissions;
|
|
|
|
Permission = ghostBookshelf.Model.extend({
|
|
|
|
tableName: 'permissions',
|
|
|
|
relationships: ['roles'],
|
|
relationshipBelongsTo: {
|
|
roles: 'roles'
|
|
},
|
|
|
|
/**
|
|
* The base model keeps only the columns, which are defined in the schema.
|
|
* We have to add the relations on top, otherwise bookshelf-relations
|
|
* has no access to the nested relations, which should be updated.
|
|
*/
|
|
permittedAttributes: function permittedAttributes() {
|
|
let filteredKeys = ghostBookshelf.Model.prototype.permittedAttributes.apply(this, arguments);
|
|
|
|
this.relationships.forEach((key) => {
|
|
filteredKeys.push(key);
|
|
});
|
|
|
|
return filteredKeys;
|
|
},
|
|
|
|
roles: function roles() {
|
|
return this.belongsToMany('Role', 'permissions_roles', 'permission_id', 'role_id');
|
|
},
|
|
|
|
users: function users() {
|
|
return this.belongsToMany('User');
|
|
}
|
|
});
|
|
|
|
Permissions = ghostBookshelf.Collection.extend({
|
|
model: Permission
|
|
});
|
|
|
|
module.exports = {
|
|
Permission: ghostBookshelf.model('Permission', Permission),
|
|
Permissions: ghostBookshelf.collection('Permissions', Permissions)
|
|
};
|