From 4b1c35119566792c36ec98c13783c422ff2a4582 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 6 Apr 2024 22:00:03 +0300 Subject: [PATCH] server-ts: Convert routes/api/password --- src/routes/api/{password.js => password.ts} | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename src/routes/api/{password.js => password.ts} (68%) diff --git a/src/routes/api/password.js b/src/routes/api/password.ts similarity index 68% rename from src/routes/api/password.js rename to src/routes/api/password.ts index 42bd8b0e0..5fb4c89d6 100644 --- a/src/routes/api/password.js +++ b/src/routes/api/password.ts @@ -1,9 +1,10 @@ "use strict"; -const passwordService = require('../../services/encryption/password'); -const ValidationError = require('../../errors/validation_error'); +import passwordService = require('../../services/encryption/password'); +import ValidationError = require('../../errors/validation_error'); +import { Request } from 'express'; -function changePassword(req) { +function changePassword(req: Request) { if (passwordService.isPasswordSet()) { return passwordService.changePassword(req.body.current_password, req.body.new_password); } @@ -12,7 +13,7 @@ function changePassword(req) { } } -function resetPassword(req) { +function resetPassword(req: Request) { // protection against accidental call (not a security measure) if (req.query.really !== "yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes") { throw new ValidationError("Incorrect password reset confirmation"); @@ -21,7 +22,7 @@ function resetPassword(req) { return passwordService.resetPassword(); } -module.exports = { +export = { changePassword, resetPassword };