30 lines
860 B
TypeScript
30 lines
860 B
TypeScript
|
import { Authorized, JsonController, Post, QueryParam } from 'routing-controllers';
|
||
|
import { OpenAPI } from 'routing-controllers-openapi';
|
||
|
import { Mailer } from '../Mailer';
|
||
|
|
||
|
/**
|
||
|
* The mail controller handels all endpoints concerning Mail sending.
|
||
|
*/
|
||
|
@JsonController()
|
||
|
@Authorized()
|
||
|
@OpenAPI({ security: [{ "AuthToken": [] }] })
|
||
|
export class MailController {
|
||
|
private mailer: Mailer = new Mailer();
|
||
|
private initialized: boolean = false;
|
||
|
|
||
|
@Post('/reset')
|
||
|
@OpenAPI({ description: "Sends reset mails" })
|
||
|
async sendReset(@QueryParam("locale") locale: string) {
|
||
|
if (!this.initialized) {
|
||
|
await this.mailer.init();
|
||
|
this.initialized = true;
|
||
|
}
|
||
|
try {
|
||
|
this.mailer.sendResetMail("todo", "lelele", locale)
|
||
|
} catch (error) {
|
||
|
throw error;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
}
|