feat: ability to enable/disable email confirmation from env variables

This commit is contained in:
Ahmed Bouhuolia
2024-05-03 18:30:19 +02:00
parent cb88c234d1
commit f4440c9a03
8 changed files with 39 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
import { Inject, Service } from 'typedi';
import { ServiceError } from '@/exceptions';
import { SystemUser } from '@/system/models';
import { Inject, Service } from 'typedi';
import { ERRORS } from './_constants';
@Service()
@@ -9,18 +9,19 @@ export class AuthSignupConfirmResend {
private agenda: any;
/**
*
* @param {number} tenantId
* @param {string} email
* Resends the email confirmation of the given user.
* @param {number} userId - User ID.
* @returns {Promise<void>}
*/
public async signUpConfirmResend(userId: number) {
const user = await SystemUser.query().findById(userId).throwIfNotFound();
//
// Throw error if the user is already verified.
if (user.verified) {
throw new ServiceError(ERRORS.USER_ALREADY_VERIFIED);
}
if (user.verifyToken) {
// Throw error if the verification token is not exist.
if (!user.verifyToken) {
throw new ServiceError(ERRORS.USER_ALREADY_VERIFIED);
}
const payload = {