mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix password change
This commit is contained in:
parent
e1251222cc
commit
a73afa9ded
@ -87,15 +87,15 @@ settings.addModule((function() {
|
|||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: result => {
|
success: result => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
alert("Password has been changed. Trilium will be reloaded after you press OK.");
|
||||||
|
|
||||||
// encryption password changed so current encryption session is invalid and needs to be cleared
|
// encryption password changed so current encryption session is invalid and needs to be cleared
|
||||||
encryption.resetEncryptionSession();
|
encryption.resetEncryptionSession();
|
||||||
|
|
||||||
encryption.setEncryptedDataKey(result.new_encrypted_data_key);
|
encryption.setEncryptedDataKey(result.new_encrypted_data_key);
|
||||||
|
|
||||||
message("Password has been changed.");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
message(result.message);
|
error(result.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: () => error("Error occurred during changing password.")
|
error: () => error("Error occurred during changing password.")
|
||||||
|
@ -7,7 +7,7 @@ const changePassword = require('../../services/change_password');
|
|||||||
const auth = require('../../services/auth');
|
const auth = require('../../services/auth');
|
||||||
|
|
||||||
router.post('/change', auth.checkApiAuth, async (req, res, next) => {
|
router.post('/change', auth.checkApiAuth, async (req, res, next) => {
|
||||||
const result = await changePassword.changePassword(req.body['current_password'], req.body['new_password']);
|
const result = await changePassword.changePassword(req.body['current_password'], req.body['new_password'], req);
|
||||||
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@ const audit_category = require('./audit_category');
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const aesjs = require('./aes');
|
const aesjs = require('./aes');
|
||||||
|
|
||||||
async function changePassword(currentPassword, newPassword, req = null) {
|
async function changePassword(currentPassword, newPassword, req) {
|
||||||
const current_password_hash = utils.toBase64(await my_scrypt.getVerificationHash(currentPassword));
|
const current_password_hash = utils.toBase64(await my_scrypt.getVerificationHash(currentPassword));
|
||||||
|
|
||||||
if (current_password_hash !== await options.getOption('password_verification_hash')) {
|
if (current_password_hash !== await options.getOption('password_verification_hash')) {
|
||||||
@ -37,12 +37,8 @@ async function changePassword(currentPassword, newPassword, req = null) {
|
|||||||
|
|
||||||
const digest = crypto.createHash('sha256').update(plainTextBuffer).digest().slice(0, 4);
|
const digest = crypto.createHash('sha256').update(plainTextBuffer).digest().slice(0, 4);
|
||||||
|
|
||||||
console.log("Digest:", digest);
|
|
||||||
|
|
||||||
const encryptedBytes = aes.encrypt(Buffer.concat([digest, plainTextBuffer]));
|
const encryptedBytes = aes.encrypt(Buffer.concat([digest, plainTextBuffer]));
|
||||||
|
|
||||||
console.log("Encrypted", encryptedBytes);
|
|
||||||
|
|
||||||
return utils.toBase64(encryptedBytes);
|
return utils.toBase64(encryptedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ function hmac(secret, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function browserId(req) {
|
function browserId(req) {
|
||||||
return req.get('x-browser-id');
|
return req == null ? null : req.get('x-browser-id');
|
||||||
}
|
}
|
||||||
|
|
||||||
function isElectron() {
|
function isElectron() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user