Compare commits

...

3 Commits

Author SHA1 Message Date
9a1678acf0 Now using mailer as static funtion
ref #151
2021-03-04 16:11:35 +01:00
485c247cd3 Removed (now useless) mail controller
ref #151
2021-03-04 16:11:21 +01:00
ddea02db57 Added new mailer settings to config
ref #151
2021-03-04 16:11:05 +01:00
3 changed files with 4 additions and 34 deletions

View File

@ -13,7 +13,9 @@ export const config = {
seedTestData: getDataSeeding(),
app_url: process.env.APP_URL || "http://localhost:8080",
privacy_url: process.env.PRIVACY_URL || "/privacy",
imprint_url: process.env.IMPRINT_URL || "/imprint"
imprint_url: process.env.IMPRINT_URL || "/imprint",
mailer_url: process.env.MAILER_URL || "http://localhost:8080/mailer",
mailer_key: process.env.MAILER_KEY || "pleasesetme"
}
let errors = 0
if (typeof config.internal_port !== "number") {

View File

@ -15,12 +15,6 @@ import { Logout } from '../models/responses/ResponseLogout';
@JsonController('/auth')
export class AuthController {
private mailer: Mailer;
constructor() {
this.mailer = new Mailer();
}
@Post("/login")
@ResponseSchema(ResponseAuth)
@ResponseSchema(InvalidCredentialsError)
@ -94,7 +88,7 @@ export class AuthController {
@OpenAPI({ description: "Request a password reset token. <br> This will provide you with a reset token that you can use by posting to /api/auth/reset/{token}." })
async getResetToken(@Body({ validate: true }) passwordReset: CreateResetToken) {
const reset_token: string = await passwordReset.toResetToken();
await this.mailer.sendResetMail(passwordReset.email, reset_token);
await Mailer.sendResetMail(passwordReset.email, reset_token);
return new ResponseEmpty();
}

View File

@ -1,26 +0,0 @@
import { Authorized, JsonController, Post } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { config } from '../config';
import { Mailer } from '../mailer';
import { ResponseEmpty } from '../models/responses/ResponseEmpty';
@JsonController('/mails')
@OpenAPI({ security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
export class MailController {
private mailer: Mailer;
constructor() {
this.mailer = new Mailer();
}
@Post('/test')
@Authorized(["MAIL:CREATE"])
@ResponseSchema(ResponseEmpty, { statusCode: 200 })
@OpenAPI({ description: 'Sends a test email to the configured from-address.' })
async get() {
await this.mailer.sendTestMail(config.mail_from);
return new ResponseEmpty();
}
}