moved protected session expiration scheduling #2855

This commit is contained in:
zadam 2022-05-17 20:39:21 +02:00
parent c24c807921
commit 37eb16b2f3
2 changed files with 15 additions and 13 deletions

View file

@ -3,7 +3,6 @@
const log = require('./log');
const dataEncryptionService = require('./data_encryption');
const options = require("./options");
const sqlInit = require("./sql_init");
let dataKey = null;
@ -64,8 +63,7 @@ function touchProtectedSession() {
}
}
sqlInit.dbReady.then(() => {
setInterval(() => {
function checkProtectedSessionExpiration() {
const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout');
if (isProtectedSessionAvailable()
&& lastProtectedSessionOperationDate
@ -73,11 +71,11 @@ sqlInit.dbReady.then(() => {
resetDataKey();
log.info("Expiring protected session");
require('./ws').reloadFrontend();
}
}, 30000);
});
}
module.exports = {
setDataKey,
@ -87,5 +85,6 @@ module.exports = {
decrypt,
decryptString,
decryptNotes,
touchProtectedSession
touchProtectedSession,
checkProtectedSessionExpiration
};

View file

@ -6,6 +6,7 @@ const log = require('./log');
const sql = require("./sql");
const becca = require("../becca/becca");
const specialNotesService = require("../services/special_notes");
const protectedSessionService = require("../services/protected_session");
function getRunAtHours(note) {
try {
@ -59,4 +60,6 @@ sqlInit.dbReady.then(() => {
setTimeout(cls.wrap(() => specialNotesService.createMissingSpecialNotes()), 10 * 1000);
}
setInterval(() => protectedSessionService.checkProtectedSessionExpiration(), 30000);
});