mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
e6f7c706cb
- Created Role model - Created Permission model - Linked Users->Roles with a belongsToMany relationship - Linked Permissions to Users and Roles with a belongsToMany relationship - Created permissions helper with functions for initializing and checking permissions (canThis) - Unit tests for lots of things
32 lines
619 B
JavaScript
32 lines
619 B
JavaScript
(function () {
|
|
|
|
"use strict";
|
|
|
|
var User = require('./user').User,
|
|
Permission = require('./permission').Permission,
|
|
GhostBookshelf = require('./base'),
|
|
Role,
|
|
Roles;
|
|
|
|
Role = GhostBookshelf.Model.extend({
|
|
tableName: 'roles',
|
|
|
|
users: function () {
|
|
return this.belongsToMany(User);
|
|
},
|
|
|
|
permissions: function () {
|
|
return this.belongsToMany(Permission);
|
|
}
|
|
});
|
|
|
|
Roles = GhostBookshelf.Collection.extend({
|
|
model: Role
|
|
});
|
|
|
|
module.exports = {
|
|
Role: Role,
|
|
Roles: Roles
|
|
};
|
|
|
|
}()); |