mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-04-23 21:29:02 -05:00
encryption timeout is now configurable in the db
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
@@ -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 #
|
||||
|
||||
Reference in New Issue
Block a user