mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-17 05:09: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 {
|
export class ResendVerificationEmailDto {
|
||||||
@IsUUID()
|
@IsUUID()
|
||||||
userId: string
|
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 { UsersRepository } from '../../users/infrastructure/users.repository'
|
||||||
import { UsersService } from '../../users/services/users.service'
|
import { UsersService } from '../../users/services/users.service'
|
||||||
|
import { ResendVerificationEmailDto } from '../dto'
|
||||||
|
|
||||||
export class ResendVerificationEmailCommand {
|
export class ResendVerificationEmailCommand {
|
||||||
constructor(public readonly userId: string) {}
|
constructor(public readonly body: ResendVerificationEmailDto) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandHandler(ResendVerificationEmailCommand)
|
@CommandHandler(ResendVerificationEmailCommand)
|
||||||
@@ -18,7 +19,7 @@ export class ResendVerificationEmailHandler
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async execute(command: ResendVerificationEmailCommand) {
|
async execute(command: ResendVerificationEmailCommand) {
|
||||||
const user = await this.usersRepository.findUserById(command.userId)
|
const user = await this.usersRepository.findUserById(command.body.userId)
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new NotFoundException('User not found')
|
throw new NotFoundException('User not found')
|
||||||
@@ -34,6 +35,8 @@ export class ResendVerificationEmailHandler
|
|||||||
email: updatedUser.user.email,
|
email: updatedUser.user.email,
|
||||||
name: updatedUser.user.name,
|
name: updatedUser.user.name,
|
||||||
verificationToken: updatedUser.verificationToken,
|
verificationToken: updatedUser.verificationToken,
|
||||||
|
html: command.body.html,
|
||||||
|
subject: command.body.subject,
|
||||||
})
|
})
|
||||||
if (!updatedUser) {
|
if (!updatedUser) {
|
||||||
throw new NotFoundException('User not found')
|
throw new NotFoundException('User not found')
|
||||||
|
|||||||
Reference in New Issue
Block a user