summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.js3
-rw-r--r--source/session.js5
2 files changed, 6 insertions, 2 deletions
diff --git a/app.js b/app.js
index 84c283c..9a466d8 100644
--- a/app.js
+++ b/app.js
@@ -186,9 +186,10 @@ class App {
}
#ValidateCookie(req, res, next) {
const { cookies } = req
- session().Expired()
if ('session_id' in cookies) {
if (session().Exists(cookies.session_id.replace('session_id', ''))) {
+ session().Expired()
+ } else {
res.clearCookie('session_id')
res.cookie('session_id', session().Create())
}
diff --git a/source/session.js b/source/session.js
index 5846271..40d0563 100644
--- a/source/session.js
+++ b/source/session.js
@@ -13,7 +13,10 @@ class Session {
sessions.set(object.result, Date.now() + (1000 * 60 * 60))
return object.result
}
- Exists(x) {return sessions.has(x)}
+ Exists(x) {
+ sessions.set(x, Date.now() + (1000 * 60 * 60))
+ return sessions.has(x)
+ }
Expired() {sessions.forEach((value, key) => {if (Date.now() > value) sessions.delete(key)})}
}