mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
Permissions authorization middleware.
This commit is contained in:
@@ -18,8 +18,11 @@ const Account = bookshelf.Model.extend({
|
||||
return this.belongsTo('AccountType', 'account_type_id');
|
||||
},
|
||||
|
||||
/**
|
||||
* Account model may has many balances accounts.
|
||||
*/
|
||||
balances() {
|
||||
return this.hasMany('AccountBalance', 'accounnt_id');
|
||||
return this.hasMany('AccountBalance', 'account_id');
|
||||
},
|
||||
}, {
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import bookshelf from './bookshelf';
|
||||
|
||||
const Item = bookshelf.Model.extend({
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
@@ -25,6 +24,11 @@ const Item = bookshelf.Model.extend({
|
||||
category() {
|
||||
return this.belongsTo('ItemCategory', 'category_id');
|
||||
},
|
||||
}, {
|
||||
/**
|
||||
* Cascade delete dependents.
|
||||
*/
|
||||
dependents: ['ItemMetadata'],
|
||||
});
|
||||
|
||||
export default bookshelf.model('Item', Item);
|
||||
|
||||
@@ -24,6 +24,10 @@ const Resource = bookshelf.Model.extend({
|
||||
fields() {
|
||||
return this.hasMany('ResourceField', 'resource_id');
|
||||
},
|
||||
|
||||
permissions() {
|
||||
return this.belongsToMany('Permission', 'role_has_permissions', 'resource_id', 'permission_id');
|
||||
},
|
||||
});
|
||||
|
||||
export default bookshelf.model('Resource', Resource);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import bcrypt from 'bcryptjs';
|
||||
import bookshelf from './bookshelf';
|
||||
import PermissionsService from '@/services/PermissionsService';
|
||||
|
||||
const User = bookshelf.Model.extend({
|
||||
...PermissionsService,
|
||||
|
||||
/**
|
||||
* Table name
|
||||
@@ -13,6 +15,10 @@ const User = bookshelf.Model.extend({
|
||||
*/
|
||||
hasTimestamps: ['created_at', 'updated_at'],
|
||||
|
||||
initialize() {
|
||||
this.initializeCache();
|
||||
},
|
||||
|
||||
/**
|
||||
* Verify the password of the user.
|
||||
* @param {String} password - The given password.
|
||||
|
||||
Reference in New Issue
Block a user