mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: Disable email confirmation does not work with invited users
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Container, Inject } from 'typedi';
|
import { Container, Inject } from 'typedi';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
import { Tenant } from '@/system/models';
|
import { SystemUser, Tenant } from '@/system/models';
|
||||||
import {
|
import {
|
||||||
IAuthSignedInEventPayload,
|
IAuthSignedInEventPayload,
|
||||||
IAuthSigningInEventPayload,
|
IAuthSigningInEventPayload,
|
||||||
@@ -64,7 +64,9 @@ export class AuthSigninService {
|
|||||||
const { systemUserRepository } = this.sysRepositories;
|
const { systemUserRepository } = this.sysRepositories;
|
||||||
|
|
||||||
// Finds the user of the given email address.
|
// Finds the user of the given email address.
|
||||||
const user = await systemUserRepository.findOneByEmail(email);
|
const user = await SystemUser.query()
|
||||||
|
.findOne('email', email)
|
||||||
|
.modify('inviteAccepted');
|
||||||
|
|
||||||
// Validate the given email and password.
|
// Validate the given email and password.
|
||||||
await this.validateSignIn(user, email, password);
|
await this.validateSignIn(user, email, password);
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ export default class SyncSystemSendInvite {
|
|||||||
email: user.email,
|
email: user.email,
|
||||||
active: user.active,
|
active: user.active,
|
||||||
tenantId,
|
tenantId,
|
||||||
|
|
||||||
|
// Email should be verified since the user got the invite token through email.
|
||||||
|
verified: true,
|
||||||
});
|
});
|
||||||
// Creates a invite user token.
|
// Creates a invite user token.
|
||||||
const invite = await Invite.query().insert({
|
const invite = await Invite.query().insert({
|
||||||
|
|||||||
@@ -90,6 +90,20 @@ export default class SystemUser extends SystemModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model modifiers.
|
||||||
|
*/
|
||||||
|
static get modifiers() {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* Filters the invite accepted users.
|
||||||
|
*/
|
||||||
|
inviteAccepted(query) {
|
||||||
|
query.whereNotNull('invite_accepted_at');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify the password of the user.
|
* Verify the password of the user.
|
||||||
* @param {String} password - The given password.
|
* @param {String} password - The given password.
|
||||||
|
|||||||
Reference in New Issue
Block a user