mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: accounts slug. feat: duplicate accounts_balance table and merge balance with accounts table. feat: refactoring customers and vendors. feat: system user soft deleting. feat: preventing build tenant database without any subscription. feat: remove 'password' property from 'req.user' object. feat: refactoring JournalPoster class. feat: delete duplicated directories and files.
56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
import { Model, mixin } from 'objection';
|
|
import bcrypt from 'bcryptjs';
|
|
import SoftDelete from 'objection-soft-delete';
|
|
import SystemModel from '@/system/models/SystemModel';
|
|
import moment from 'moment';
|
|
|
|
export default class SystemUser extends mixin(SystemModel, [SoftDelete({
|
|
columnName: 'deleted_at',
|
|
deletedValue: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
notDeletedValue: null,
|
|
})]) {
|
|
/**
|
|
* Table name.
|
|
*/
|
|
static get tableName() {
|
|
return 'users';
|
|
}
|
|
|
|
/**
|
|
* Timestamps columns.
|
|
*/
|
|
get timestamps() {
|
|
return ['createdAt', 'updatedAt'];
|
|
}
|
|
|
|
/**
|
|
* Relationship mapping.
|
|
*/
|
|
static get relationMappings() {
|
|
const Tenant = require('@/system/models/Tenant');
|
|
|
|
return {
|
|
/**
|
|
* System user may belongs to tenant model.
|
|
*/
|
|
tenant: {
|
|
relation: Model.BelongsToOneRelation,
|
|
modelClass: Tenant.default,
|
|
join: {
|
|
from: 'users.tenantId',
|
|
to: 'tenants.id',
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Verify the password of the user.
|
|
* @param {String} password - The given password.
|
|
* @return {Boolean}
|
|
*/
|
|
verifyPassword(password) {
|
|
return bcrypt.compareSync(password, this.password);
|
|
}
|
|
}
|