Now accepting reset mail class
This commit is contained in:
parent
5812a485ee
commit
7445223f1e
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ export class ResetMail {
|
|||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
toAddress: string;
|
address: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
resetLink: string;
|
resetKey: string;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user