Skip to content

Commit

Permalink
delay protected session expiration check after DB init, fixes #2855
Browse files Browse the repository at this point in the history
  • Loading branch information
zadam committed May 17, 2022
1 parent dbb5d02 commit c24c807
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/services/protected_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const log = require('./log');
const dataEncryptionService = require('./data_encryption');
const options = require("./options");
const sqlInit = require("./sql_init");

let dataKey = null;

Expand Down Expand Up @@ -63,17 +64,19 @@ function touchProtectedSession() {
}
}

setInterval(() => {
const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout');
if (isProtectedSessionAvailable()
&& lastProtectedSessionOperationDate
&& Date.now() - lastProtectedSessionOperationDate > protectedSessionTimeout * 1000) {
sqlInit.dbReady.then(() => {
setInterval(() => {
const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout');
if (isProtectedSessionAvailable()
&& lastProtectedSessionOperationDate
&& Date.now() - lastProtectedSessionOperationDate > protectedSessionTimeout * 1000) {

resetDataKey();
resetDataKey();

require('./ws').reloadFrontend();
}
}, 30000);
require('./ws').reloadFrontend();
}
}, 30000);
});


module.exports = {
Expand Down

0 comments on commit c24c807

Please sign in to comment.