From a5d2a6ecd31dc9c186d4201aef5c52e34cbef3b5 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 4 Mar 2021 16:25:23 +0100 Subject: [PATCH] Added locale to pw reset endpoint ref #151 --- src/controllers/AuthController.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controllers/AuthController.ts b/src/controllers/AuthController.ts index b3e2999..eebbd79 100644 --- a/src/controllers/AuthController.ts +++ b/src/controllers/AuthController.ts @@ -1,6 +1,7 @@ -import { Body, CookieParam, JsonController, Param, Post, Req, Res } from 'routing-controllers'; +import { Body, CookieParam, JsonController, Param, Post, QueryParam, Req, Res } from 'routing-controllers'; import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { IllegalJWTError, InvalidCredentialsError, JwtNotProvidedError, PasswordNeededError, RefreshTokenCountInvalidError, UsernameOrEmailNeededError } from '../errors/AuthError'; +import { MailSendingError } from '../errors/MailErrors'; import { UserNotFoundError } from '../errors/UserErrors'; import { Mailer } from '../mailer'; import { CreateAuth } from '../models/actions/create/CreateAuth'; @@ -85,10 +86,11 @@ export class AuthController { @ResponseSchema(ResponseEmpty, { statusCode: 200 }) @ResponseSchema(UserNotFoundError, { statusCode: 404 }) @ResponseSchema(UsernameOrEmailNeededError, { statusCode: 406 }) + @ResponseSchema(MailSendingError, { statusCode: 500 }) @OpenAPI({ description: "Request a password reset token.
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, @QueryParam("locale") locale: string = "en") { const reset_token: string = await passwordReset.toResetToken(); - await Mailer.sendResetMail(passwordReset.email, reset_token); + await Mailer.sendResetMail(passwordReset.email, reset_token, locale); return new ResponseEmpty(); }