summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMhykol <mchaeldonald62@pm.me>2024-10-13 03:23:29 -0400
committerMhykol <mchaeldonald62@pm.me>2024-10-13 03:23:29 -0400
commit94a1189d8becec42ed0d949b3d441e5006bf68d9 (patch)
tree2617bdbe1bb26175820d117f1798773d13adf8b1
parent611aa084110b24dc00757bc02f647f1675df8dda (diff)
Fixed sessions
-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)})}
}