From 2103880d61b7b9bd81ab3e6f3d9a3471fa236caf Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 5 Aug 2016 21:54:47 +0300 Subject: [PATCH] only extend 5mins if less than 5mins left --- src/middleware/middleware.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js index afae4957ea..62dcc97d4c 100644 --- a/src/middleware/middleware.js +++ b/src/middleware/middleware.js @@ -206,7 +206,11 @@ 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; + var timeLeft = parseInt(loginTime, 10) - (Date.now() - 3600000); + if (timeLeft < 300000) { + req.session.meta.datetime += 300000; + } + return next(); }