encryption timeout is now configurable in the db

This commit is contained in:
azivner
2017-09-12 23:04:17 -04:00
parent 3e97cdf085
commit 5b84487aac
7 changed files with 79 additions and 5 deletions
+1 -4
View File
@@ -24,9 +24,6 @@ function handleEncryption(requireEncryption, modal, callback) {
}
}
// currently not configurable
const globalEncryptionKeyTimeToLive = 10 * 60 * 1000; // in milliseconds
let globalEncryptionKey = null;
let globalLastEncryptionOperationDate = null;
@@ -119,7 +116,7 @@ $("#encryptionPasswordForm").submit(function() {
});
setInterval(function() {
if (globalLastEncryptionOperationDate !== null && new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionKeyTimeToLive) {
if (globalLastEncryptionOperationDate !== null && new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionSessionTimeout * 1000) {
globalEncryptionKey = null;
if (globalCurrentNote.detail.encryption > 0) {
+29
View File
@@ -1,4 +1,13 @@
function displaySettings() {
$.ajax({
url: baseUrl + 'settings',
type: 'GET',
success: function (result) {
$("#encryptionTimeoutInSeconds").val(result['encryption_session_timeout']);
},
error: () => alert("Error getting settings.")
});
$("#settingsDialog").dialog({
modal: true,
width: 600
@@ -40,5 +49,25 @@ $("#changePasswordForm").submit(() => {
error: () => alert("Error occurred during changing password.")
});
return false;
});
$("#encryptionTimeoutForm").submit(() => {
const encryptionTimeout = $("#encryptionTimeoutInSeconds").val();
$.ajax({
url: baseUrl + 'settings',
type: 'POST',
data: JSON.stringify({
name: 'encryption_session_timeout',
value: encryptionTimeout
}),
contentType: "application/json",
success: function () {
alert("Encryption timeout has been changed.");
},
error: () => alert("Error occurred during changing encryption timeout.")
});
return false;
});
+2
View File
@@ -85,6 +85,7 @@ function setExpandedToServer(note_id, is_expanded) {
let globalVerificationSalt;
let globalEncryptionSalt;
let globalEncryptionSessionTimeout;
$(function(){
$.get(baseUrl + 'tree').then(resp => {
@@ -92,6 +93,7 @@ $(function(){
let startNoteId = resp.start_note_id;
globalVerificationSalt = resp.verification_salt;
globalEncryptionSalt = resp.encryption_salt;
globalEncryptionSessionTimeout = resp.encryption_session_timeout;
if (document.location.hash) {
startNoteId = document.location.hash.substr(1); // strip initial #