From 4e298d9d85e6071d8ee4b9433038e8fe46283baa Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 12 Sep 2017 23:07:08 -0400 Subject: [PATCH] after changing password, encryption key changed so current encryption session is invalid and needs to be cleared --- static/js/encryption.js | 24 ++++++++++++++---------- static/js/settings.js | 3 +++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/static/js/encryption.js b/static/js/encryption.js index 22ccb48c5..cbbe1b46d 100644 --- a/static/js/encryption.js +++ b/static/js/encryption.js @@ -115,22 +115,26 @@ $("#encryptionPasswordForm").submit(function() { return false; }); -setInterval(function() { - if (globalLastEncryptionOperationDate !== null && new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionSessionTimeout * 1000) { - globalEncryptionKey = null; +function resetEncryptionSession() { + globalEncryptionKey = null; - if (globalCurrentNote.detail.encryption > 0) { - loadNote(globalCurrentNote.detail.note_id); + if (globalCurrentNote.detail.encryption > 0) { + loadNote(globalCurrentNote.detail.note_id); - for (const noteId of globalAllNoteIds) { - const note = getNodeByKey(noteId); + for (const noteId of globalAllNoteIds) { + const note = getNodeByKey(noteId); - if (note.data.encryption > 0) { - note.setTitle("[encrypted]"); - } + if (note.data.encryption > 0) { + note.setTitle("[encrypted]"); } } } +} + +setInterval(function() { + if (globalLastEncryptionOperationDate !== null && new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionSessionTimeout * 1000) { + resetEncryptionSession(); + } }, 5000); function isEncryptionAvailable() { diff --git a/static/js/settings.js b/static/js/settings.js index 637ccda91..ed3712277 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -40,6 +40,9 @@ $("#changePasswordForm").submit(() => { contentType: "application/json", success: function (result) { if (result.success) { + // encryption password changed so current encryption session is invalid and needs to be cleared + resetEncryptionSession(); + alert("Password has been changed."); } else {