mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
encryption settings loading moved from tree to encryption module
This commit is contained in:
parent
dfaa59b0a9
commit
9c88fc6060
@ -12,6 +12,16 @@ const encryption = (function() {
|
|||||||
let encryptedDataKey = null;
|
let encryptedDataKey = null;
|
||||||
let encryptionSessionTimeout = null;
|
let encryptionSessionTimeout = null;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: baseApiUrl + 'settings/all',
|
||||||
|
type: 'GET',
|
||||||
|
error: () => error("Error getting encryption settings.")
|
||||||
|
}).then(settings => {
|
||||||
|
encryptionSalt = settings.password_derived_key_salt;
|
||||||
|
encryptionSessionTimeout = settings.encryption_session_timeout;
|
||||||
|
encryptedDataKey = settings.encrypted_data_key;
|
||||||
|
});
|
||||||
|
|
||||||
function setEncryptionSalt(encSalt) {
|
function setEncryptionSalt(encSalt) {
|
||||||
encryptionSalt = encSalt;
|
encryptionSalt = encSalt;
|
||||||
}
|
}
|
||||||
@ -438,7 +448,6 @@ const encryption = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setEncryptionSalt,
|
|
||||||
setEncryptedDataKey,
|
setEncryptedDataKey,
|
||||||
setEncryptionSessionTimeout,
|
setEncryptionSessionTimeout,
|
||||||
ensureEncryptionIsAvailable,
|
ensureEncryptionIsAvailable,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const glob = {
|
const glob = {
|
||||||
|
allNoteIds: [],
|
||||||
activeDialog: null
|
activeDialog: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ const noteTree = (function() {
|
|||||||
let treeLoadTime = null;
|
let treeLoadTime = null;
|
||||||
let clipboardNoteId = null;
|
let clipboardNoteId = null;
|
||||||
|
|
||||||
glob.allNoteIds = [];
|
|
||||||
|
|
||||||
function getTreeLoadTime() {
|
function getTreeLoadTime() {
|
||||||
return treeLoadTime;
|
return treeLoadTime;
|
||||||
}
|
}
|
||||||
@ -194,9 +192,6 @@ const noteTree = (function() {
|
|||||||
return $.get(baseApiUrl + 'tree').then(resp => {
|
return $.get(baseApiUrl + 'tree').then(resp => {
|
||||||
const notes = resp.notes;
|
const notes = resp.notes;
|
||||||
let startNoteId = resp.start_note_id;
|
let startNoteId = resp.start_note_id;
|
||||||
encryption.setEncryptionSalt(resp.password_derived_key_salt);
|
|
||||||
encryption.setEncryptionSessionTimeout(resp.encryption_session_timeout);
|
|
||||||
encryption.setEncryptedDataKey(resp.encrypted_data_key);
|
|
||||||
treeLoadTime = resp.tree_load_time;
|
treeLoadTime = resp.tree_load_time;
|
||||||
|
|
||||||
// add browser ID header to all AJAX requests
|
// add browser ID header to all AJAX requests
|
||||||
|
@ -7,19 +7,20 @@ const options = require('../../services/options');
|
|||||||
const audit_category = require('../../services/audit_category');
|
const audit_category = require('../../services/audit_category');
|
||||||
const auth = require('../../services/auth');
|
const auth = require('../../services/auth');
|
||||||
|
|
||||||
|
// options allowed to be updated directly in settings dialog
|
||||||
const ALLOWED_OPTIONS = ['encryption_session_timeout', 'history_snapshot_time_interval'];
|
const ALLOWED_OPTIONS = ['encryption_session_timeout', 'history_snapshot_time_interval'];
|
||||||
|
|
||||||
router.get('/', auth.checkApiAuth, async (req, res, next) => {
|
router.get('/all', auth.checkApiAuth, async (req, res, next) => {
|
||||||
const dict = {};
|
const settings = await sql.getMap("SELECT opt_name, opt_value FROM options");
|
||||||
|
|
||||||
const settings = await sql.getResults("SELECT opt_name, opt_value FROM options WHERE opt_name IN ("
|
res.send(settings);
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get('/', auth.checkApiAuth, async (req, res, next) => {
|
||||||
|
const settings = await sql.getMap("SELECT opt_name, opt_value FROM options WHERE opt_name IN ("
|
||||||
+ ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS);
|
+ ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS);
|
||||||
|
|
||||||
for (const set of settings) {
|
res.send(settings);
|
||||||
dict[set['opt_name']] = set['opt_value'];
|
|
||||||
}
|
|
||||||
|
|
||||||
res.send(dict);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/', async (req, res, next) => {
|
router.post('/', async (req, res, next) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user