From 7445223f1e6782536157d09cddcad9c942b72e7d Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Tue, 2 Mar 2021 18:17:57 +0100 Subject: [PATCH] Now accepting reset mail class --- src/controllers/MailController.ts | 7 ++++--- src/models/ResetMail.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/controllers/MailController.ts b/src/controllers/MailController.ts index 5d55dcc..337318f 100644 --- a/src/controllers/MailController.ts +++ b/src/controllers/MailController.ts @@ -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; } diff --git a/src/models/ResetMail.ts b/src/models/ResetMail.ts index ef31a8a..2c8651d 100644 --- a/src/models/ResetMail.ts +++ b/src/models/ResetMail.ts @@ -7,9 +7,9 @@ export class ResetMail { @IsString() @IsNotEmpty() - toAddress: string; + address: string; @IsString() @IsNotEmpty() - resetLink: string; + resetKey: string; } \ No newline at end of file