diff --git a/public/language/en_GB/login.json b/public/language/en_GB/login.json index e76658fe3d..97c6dedb37 100644 --- a/public/language/en_GB/login.json +++ b/public/language/en_GB/login.json @@ -7,5 +7,6 @@ "alternative_logins": "Alternative Logins", "failed_login_attempt": "Login Unsuccessful", "login_successful": "You have successfully logged in!", - "dont_have_account": "Don't have an account?" + "dont_have_account": "Don't have an account?", + "logged-out-due-to-inactivity": "You have been logged out due to inactivity" } diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index 62234df1e9..8a26b91409 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -2,9 +2,23 @@ /*global config, translator, componentHandler, define, socket, app, ajaxify, utils, bootbox, Slideout, NProgress, RELATIVE_PATH*/ (function() { + var logoutTimer = 0; + function startLogoutTimer() { + if (logoutTimer) { + clearTimeout(logoutTimer); + } + + logoutTimer = setTimeout(function() { + app.alert({ + message: '[[login:logged-out-due-to-inactivity]]' + }); + setTimeout(app.logout, 5000); + }, 3600000); + } $(window).on('action:ajaxify.end', function() { showCorrectNavTab(); + startLogoutTimer(); }); function showCorrectNavTab() { diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js index a1c98b0c3d..afae4957ea 100644 --- a/src/middleware/middleware.js +++ b/src/middleware/middleware.js @@ -206,6 +206,7 @@ middleware.isAdmin = function(req, res, next) { var loginTime = req.session.meta ? req.session.meta.datetime : 0; if (loginTime && parseInt(loginTime, 10) > Date.now() - 3600000) { + req.session.meta.datetime += 300000; return next(); }