Added basic mail controller
This commit is contained in:
parent
c5fe1671a2
commit
972b09d8ca
29
src/controllers/MailController.ts
Normal file
29
src/controllers/MailController.ts
Normal file
@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user