mirror of
https://github.com/zadam/trilium.git
synced 2025-02-24 15:05:31 +08:00
moved protected session expiration scheduling #2855
This commit is contained in:
parent
c24c807921
commit
37eb16b2f3
2 changed files with 15 additions and 13 deletions
|
@ -3,7 +3,6 @@
|
||||||
const log = require('./log');
|
const log = require('./log');
|
||||||
const dataEncryptionService = require('./data_encryption');
|
const dataEncryptionService = require('./data_encryption');
|
||||||
const options = require("./options");
|
const options = require("./options");
|
||||||
const sqlInit = require("./sql_init");
|
|
||||||
|
|
||||||
let dataKey = null;
|
let dataKey = null;
|
||||||
|
|
||||||
|
@ -64,20 +63,19 @@ function touchProtectedSession() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlInit.dbReady.then(() => {
|
function checkProtectedSessionExpiration() {
|
||||||
setInterval(() => {
|
const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout');
|
||||||
const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout');
|
if (isProtectedSessionAvailable()
|
||||||
if (isProtectedSessionAvailable()
|
&& lastProtectedSessionOperationDate
|
||||||
&& lastProtectedSessionOperationDate
|
&& Date.now() - lastProtectedSessionOperationDate > protectedSessionTimeout * 1000) {
|
||||||
&& Date.now() - lastProtectedSessionOperationDate > protectedSessionTimeout * 1000) {
|
|
||||||
|
|
||||||
resetDataKey();
|
resetDataKey();
|
||||||
|
|
||||||
require('./ws').reloadFrontend();
|
log.info("Expiring protected session");
|
||||||
}
|
|
||||||
}, 30000);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
require('./ws').reloadFrontend();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setDataKey,
|
setDataKey,
|
||||||
|
@ -87,5 +85,6 @@ module.exports = {
|
||||||
decrypt,
|
decrypt,
|
||||||
decryptString,
|
decryptString,
|
||||||
decryptNotes,
|
decryptNotes,
|
||||||
touchProtectedSession
|
touchProtectedSession,
|
||||||
|
checkProtectedSessionExpiration
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@ const log = require('./log');
|
||||||
const sql = require("./sql");
|
const sql = require("./sql");
|
||||||
const becca = require("../becca/becca");
|
const becca = require("../becca/becca");
|
||||||
const specialNotesService = require("../services/special_notes");
|
const specialNotesService = require("../services/special_notes");
|
||||||
|
const protectedSessionService = require("../services/protected_session");
|
||||||
|
|
||||||
function getRunAtHours(note) {
|
function getRunAtHours(note) {
|
||||||
try {
|
try {
|
||||||
|
@ -59,4 +60,6 @@ sqlInit.dbReady.then(() => {
|
||||||
|
|
||||||
setTimeout(cls.wrap(() => specialNotesService.createMissingSpecialNotes()), 10 * 1000);
|
setTimeout(cls.wrap(() => specialNotesService.createMissingSpecialNotes()), 10 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setInterval(() => protectedSessionService.checkProtectedSessionExpiration(), 30000);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue