mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
resetting/setting password from options
This commit is contained in:
@@ -67,6 +67,8 @@ function getOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
resultMap['isPasswordSet'] = !!optionMap['passwordVerificationHash'] ? 'true' : 'false';
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
const changePasswordService = require('../../services/change_password');
|
||||
const passwordService = require('../../services/password.js');
|
||||
|
||||
function changePassword(req) {
|
||||
return changePasswordService.changePassword(req.body.current_password, req.body.new_password);
|
||||
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
|
||||
changePassword,
|
||||
resetPassword
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user