feat: User email verification after signing-up.

This commit is contained in:
Ahmed Bouhuolia
2024-04-26 12:21:40 +02:00
parent b7214044bb
commit 4368c18479
16 changed files with 778 additions and 8 deletions

View File

@@ -0,0 +1,35 @@
import { ServiceError } from '@/exceptions';
import { SystemUser } from '@/system/models';
import { Inject, Service } from 'typedi';
import { ERRORS } from './_constants';
@Service()
export class AuthSignupConfirmResend {
@Inject('agenda')
private agenda: any;
/**
*
* @param {number} tenantId
* @param {string} email
*/
public async signUpConfirmResend(email: string) {
const user = await SystemUser.query()
.findOne({ email })
.throwIfNotFound();
//
if (user.verified) {
throw new ServiceError(ERRORS.USER_ALREADY_VERIFIED)
}
if (user.verifyToken) {
throw new ServiceError(ERRORS.USER_ALREADY_VERIFIED);
}
const payload = {
email: user.email,
token: user.verifyToken,
fullName: user.firstName,
};
await this.agenda.now('send-signup-verify-mail', payload);
}
}