mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-24 20:59:28 +00:00
add html to signup endpoint
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { IsEmail, IsOptional, Length } from 'class-validator'
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { IsBoolean, IsEmail, IsOptional, IsString, Length } from 'class-validator'
|
||||
|
||||
export class RegistrationDto {
|
||||
@Length(3, 30)
|
||||
@@ -10,4 +11,24 @@ export class RegistrationDto {
|
||||
|
||||
@IsEmail()
|
||||
email: 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
|
||||
/** Whether to send a confirmation email or not.
|
||||
* Defaults to false
|
||||
* @example false
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
sendConfirmationEmail?: boolean
|
||||
}
|
||||
|
||||
@@ -35,10 +35,19 @@ export class CreateUserHandler implements ICommandHandler<CreateUserCommand> {
|
||||
if (!createdUser) {
|
||||
return null
|
||||
}
|
||||
if (!command.user.sendConfirmationEmail) {
|
||||
return {
|
||||
id: createdUser.id,
|
||||
name: createdUser.name,
|
||||
email: createdUser.email,
|
||||
}
|
||||
}
|
||||
await this.usersService.sendConfirmationEmail({
|
||||
email: createdUser.email,
|
||||
name: createdUser.name,
|
||||
verificationToken: verificationToken,
|
||||
html: command.user.html,
|
||||
subject: command.user.subject,
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user