mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-16 20:59:26 +00:00
add html and subject to resending verification email
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
import { IsUUID } from 'class-validator'
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { IsOptional, IsString, IsUUID } from 'class-validator'
|
||||
|
||||
export class ResendVerificationEmailDto {
|
||||
@IsUUID()
|
||||
userId: string
|
||||
|
||||
@ApiProperty({
|
||||
description: `HTML template to be sent in the email;\n ##name## will be replaced with the user's name; \n ##token## will be replaced with the password recovery token`,
|
||||
example: `<b>Hello, ##name##!</b><br/>Please confirm your email by clicking on the link below:<br/><a href="http://localhost:3000/confirm-email/##token##">Confirm email</a>. If it doesn't work, copy and paste the following link in your browser:<br/>http://localhost:3000/confirm-email/##token##`,
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
html?: string
|
||||
|
||||
/** Email subject */
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
subject?: string
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@ import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'
|
||||
|
||||
import { UsersRepository } from '../../users/infrastructure/users.repository'
|
||||
import { UsersService } from '../../users/services/users.service'
|
||||
import { ResendVerificationEmailDto } from '../dto'
|
||||
|
||||
export class ResendVerificationEmailCommand {
|
||||
constructor(public readonly userId: string) {}
|
||||
constructor(public readonly body: ResendVerificationEmailDto) {}
|
||||
}
|
||||
|
||||
@CommandHandler(ResendVerificationEmailCommand)
|
||||
@@ -18,7 +19,7 @@ export class ResendVerificationEmailHandler
|
||||
) {}
|
||||
|
||||
async execute(command: ResendVerificationEmailCommand) {
|
||||
const user = await this.usersRepository.findUserById(command.userId)
|
||||
const user = await this.usersRepository.findUserById(command.body.userId)
|
||||
|
||||
if (!user) {
|
||||
throw new NotFoundException('User not found')
|
||||
@@ -34,6 +35,8 @@ export class ResendVerificationEmailHandler
|
||||
email: updatedUser.user.email,
|
||||
name: updatedUser.user.name,
|
||||
verificationToken: updatedUser.verificationToken,
|
||||
html: command.body.html,
|
||||
subject: command.body.subject,
|
||||
})
|
||||
if (!updatedUser) {
|
||||
throw new NotFoundException('User not found')
|
||||
|
||||
Reference in New Issue
Block a user