fix(InviteUsers): fix invite users bugs.

This commit is contained in:
a.bouhuolia
2021-03-23 18:57:04 +02:00
parent ff559180fd
commit 5855d3f368
22 changed files with 543 additions and 404 deletions

View File

@@ -5,6 +5,7 @@ exports.up = function(knex) {
table.string('email').index();
table.string('token').unique().index();
table.bigInteger('tenant_id').unsigned().index().references('id').inTable('tenants');
table.integer('user_id').unsigned().index().references('id').inTable('users');
table.datetime('created_at');
});
};

View File

@@ -1,4 +1,5 @@
import SystemModel from 'system/models/SystemModel';
import moment from 'moment';
export default class UserInvite extends SystemModel {
/**
@@ -14,4 +15,16 @@ export default class UserInvite extends SystemModel {
get timestamps() {
return ['createdAt'];
}
/**
* Model modifiers.
*/
static get modifiers() {
return {
notExpired(query) {
const comp = moment().subtract(24, 'hours').toMySqlDateTime();
query.where('created_at', '>=', comp);
}
}
}
}

View File

@@ -29,7 +29,21 @@ export default class SystemUser extends SystemModel {
* Virtual attributes.
*/
static get virtualAttributes() {
return ['fullName'];
return ['fullName', 'isDeleted', 'isInviteAccepted'];
}
/**
*
*/
get isDeleted() {
return !!this.deletedAt;
}
/**
*
*/
get isInviteAccepted() {
return !!this.inviteAcceptedAt;
}
/**