delay protected session expiration check after DB init, fixes #2855

This commit is contained in:
zadam 2022-05-17 20:22:33 +02:00
parent c51e6107a1
commit 04379b4e1f

View File

@ -3,6 +3,7 @@
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;
@ -63,17 +64,19 @@ function touchProtectedSession() {
} }
} }
setInterval(() => { sqlInit.dbReady.then(() => {
const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout'); setInterval(() => {
if (isProtectedSessionAvailable() const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout');
&& lastProtectedSessionOperationDate if (isProtectedSessionAvailable()
&& Date.now() - lastProtectedSessionOperationDate > protectedSessionTimeout * 1000) { && lastProtectedSessionOperationDate
&& Date.now() - lastProtectedSessionOperationDate > protectedSessionTimeout * 1000) {
resetDataKey(); resetDataKey();
require('./ws').reloadFrontend(); require('./ws').reloadFrontend();
} }
}, 30000); }, 30000);
});
module.exports = { module.exports = {