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

View File

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