Compare commits

..

No commits in common. "9a1678acf0929dab9f84bd2c6a961b52e36172ce" and "1551a444babc025cde6e894c66d2be2c84ab26da" have entirely different histories.

3 changed files with 34 additions and 4 deletions

View File

@ -13,9 +13,7 @@ export const config = {
seedTestData: getDataSeeding(), seedTestData: getDataSeeding(),
app_url: process.env.APP_URL || "http://localhost:8080", app_url: process.env.APP_URL || "http://localhost:8080",
privacy_url: process.env.PRIVACY_URL || "/privacy", 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 let errors = 0
if (typeof config.internal_port !== "number") { if (typeof config.internal_port !== "number") {

View File

@ -15,6 +15,12 @@ import { Logout } from '../models/responses/ResponseLogout';
@JsonController('/auth') @JsonController('/auth')
export class AuthController { export class AuthController {
private mailer: Mailer;
constructor() {
this.mailer = new Mailer();
}
@Post("/login") @Post("/login")
@ResponseSchema(ResponseAuth) @ResponseSchema(ResponseAuth)
@ResponseSchema(InvalidCredentialsError) @ResponseSchema(InvalidCredentialsError)
@ -88,7 +94,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}." }) @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) { async getResetToken(@Body({ validate: true }) passwordReset: CreateResetToken) {
const reset_token: string = await passwordReset.toResetToken(); const reset_token: string = await passwordReset.toResetToken();
await Mailer.sendResetMail(passwordReset.email, reset_token); await this.mailer.sendResetMail(passwordReset.email, reset_token);
return new ResponseEmpty(); return new ResponseEmpty();
} }

View File

@ -0,0 +1,26 @@
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();
}
}