WIP Roles and permissions access control.

This commit is contained in:
Ahmed Bouhuolia
2019-09-11 21:40:09 +02:00
parent 9a8de9ca7d
commit cba17739d6
24 changed files with 847 additions and 20 deletions

View File

@@ -21,6 +21,13 @@ const User = bookshelf.Model.extend({
verifyPassword(password) {
return bcrypt.compareSync(password, this.get('password'));
},
/**
* User model may has many associated roles.
*/
roles() {
return this.belongsToMany('Role', 'user_has_roles', 'user_id', 'role_id');
},
});
export default bookshelf.model('User', User);