mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 23:35:50 +01:00
server-ts: Convert routes/api/password
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const passwordService = require('../../services/encryption/password');
|
import passwordService = require('../../services/encryption/password');
|
||||||
const ValidationError = require('../../errors/validation_error');
|
import ValidationError = require('../../errors/validation_error');
|
||||||
|
import { Request } from 'express';
|
||||||
|
|
||||||
function changePassword(req) {
|
function changePassword(req: Request) {
|
||||||
if (passwordService.isPasswordSet()) {
|
if (passwordService.isPasswordSet()) {
|
||||||
return passwordService.changePassword(req.body.current_password, req.body.new_password);
|
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)
|
// protection against accidental call (not a security measure)
|
||||||
if (req.query.really !== "yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes") {
|
if (req.query.really !== "yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes") {
|
||||||
throw new ValidationError("Incorrect password reset confirmation");
|
throw new ValidationError("Incorrect password reset confirmation");
|
||||||
@@ -21,7 +22,7 @@ function resetPassword(req) {
|
|||||||
return passwordService.resetPassword();
|
return passwordService.resetPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export = {
|
||||||
changePassword,
|
changePassword,
|
||||||
resetPassword
|
resetPassword
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user