Now accepting reset mail class

This commit is contained in:
Nicolai Ort 2021-03-02 18:17:57 +01:00
parent 5812a485ee
commit 7445223f1e
2 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,8 @@
import { Authorized, JsonController, Post, QueryParam } from 'routing-controllers';
import { Authorized, Body, JsonController, Post, QueryParam } from 'routing-controllers';
import { OpenAPI } from 'routing-controllers-openapi';
import { Mailer } from '../Mailer';
import { locales } from '../models/LocaleEnum';
import { ResetMail } from '../models/ResetMail';
import { SuccessResponse } from '../models/SuccessResponse';
/**
@ -16,13 +17,13 @@ export class MailController {
@Post('/reset')
@OpenAPI({ description: "Sends reset mails", parameters: [{ in: "query", name: "locale", schema: { type: "string", enum: ["de", "en"] } }] })
async sendReset(@QueryParam("locale") locale: locales) {
async sendReset(@Body({ validate: true }) mailOptions: ResetMail, @QueryParam("locale") locale: locales) {
if (!this.initialized) {
await this.mailer.init();
this.initialized = true;
}
try {
this.mailer.sendResetMail("todo", "lelele", locale?.toString())
this.mailer.sendResetMail(mailOptions.address, mailOptions.resetKey, locale?.toString())
} catch (error) {
throw error;
}

View File

@ -7,9 +7,9 @@ export class ResetMail {
@IsString()
@IsNotEmpty()
toAddress: string;
address: string;
@IsString()
@IsNotEmpty()
resetLink: string;
resetKey: string;
}