From a02f976891cbb1cbdc83731c01dee13e812f3717 Mon Sep 17 00:00:00 2001 From: Daniloch Date: Fri, 31 May 2024 14:13:29 -0300 Subject: [PATCH] fix: indentation problems (again and again) --- src/services/api/routes/v1/forgotPassword.ts | 96 ++++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/src/services/api/routes/v1/forgotPassword.ts b/src/services/api/routes/v1/forgotPassword.ts index 3330abc..a45f189 100644 --- a/src/services/api/routes/v1/forgotPassword.ts +++ b/src/services/api/routes/v1/forgotPassword.ts @@ -9,62 +9,62 @@ import { HydratedPNIDDocument } from '@/types/mongoose/pnid'; const router = express.Router(); router.post('/', async (request: express.Request, response: express.Response): Promise => { - const input = request.body?.input; - const hCaptchaResponse = request.body.hCaptchaResponse?.trim(); + const input = request.body?.input; + const hCaptchaResponse = request.body.hCaptchaResponse?.trim(); + + if (!disabledFeatures.captcha) { + if (!hCaptchaResponse || hCaptchaResponse === "") { + response.status(400).json({ + app: "api", + status: 400, + error: "Must fill in captcha", + }); + + return; + } - if (!disabledFeatures.captcha) { - if (!hCaptchaResponse || hCaptchaResponse === "") { - response.status(400).json({ - app: "api", - status: 400, - error: "Must fill in captcha", - }); + const captchaVerify = await hcaptcha.verify( + config.hcaptcha.secret, + hCaptchaResponse + ); - return; - } + if (!captchaVerify.success) { + response.status(400).json({ + app: "api", + status: 400, + error: "Captcha verification failed", + }); - const captchaVerify = await hcaptcha.verify( - config.hcaptcha.secret, - hCaptchaResponse - ); + return; + } + } - if (!captchaVerify.success) { - response.status(400).json({ - app: "api", - status: 400, - error: "Captcha verification failed", - }); + if (!input || input.trim() === '') { + response.status(400).json({ + app: 'api', + status: 400, + error: 'Invalid or missing input' + }); + + return; + } - return; - } - } + let pnid: HydratedPNIDDocument | null; - if (!input || input.trim() === '') { - response.status(400).json({ - app: 'api', - status: 400, - error: 'Invalid or missing input' - }); + if (validator.isEmail(input)) { + pnid = await getPNIDByEmailAddress(input); + } else { + pnid = await getPNIDByUsername(input); + } - return; - } + if (pnid) { + await sendForgotPasswordEmail(pnid); + } - let pnid: HydratedPNIDDocument | null; - - if (validator.isEmail(input)) { - pnid = await getPNIDByEmailAddress(input); - } else { - pnid = await getPNIDByUsername(input); - } - - if (pnid) { - await sendForgotPasswordEmail(pnid); - } - - response.json({ - app: 'api', - status: 200 - }); + response.json({ + app: 'api', + status: 200 + }); }); export default router; \ No newline at end of file