trilium/src/routes/api/password.js
2021-12-30 22:54:08 +01:00

27 lines
712 B
JavaScript

"use strict";
const passwordService = require('../../services/password.js');
function changePassword(req) {
if (passwordService.isPasswordSet()) {
return passwordService.changePassword(req.body.current_password, req.body.new_password);
}
else {
return passwordService.setPassword(req.body.new_password);
}
}
function resetPassword(req) {
// protection against accidental call (not a security measure)
if (req.query.really !== "yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes") {
return [400, "Incorrect password reset confirmation"];
}
return passwordService.resetPassword();
}
module.exports = {
changePassword,
resetPassword
};