[TASK] Store lastActivity as string instead of date.

This commit is contained in:
Jan Philipp Timme 2013-09-16 19:16:12 +02:00
parent f18dd39a36
commit 3d1b6369a2
2 changed files with 4 additions and 4 deletions

2
app.js
View File

@ -57,7 +57,7 @@ app.use(function(req, res, next) {
"user": null, "user": null,
"profile": {}, "profile": {},
"login": false, "login": false,
"lastActivity": new Date() "lastActivity": new Date().toString()
}; };
} }
console.log(["Session Data", req.session.data]); console.log(["Session Data", req.session.data]);

View File

@ -10,8 +10,8 @@ var constructor = function(db) {
//refresh session and return login status //refresh session and return login status
if(req.method == "GET") { if(req.method == "GET") {
if(req.session.data.login == true) { if(req.session.data.login == true) {
if(new Date() - req.session.data.lastActivity < 5 * 60 * 1000) { if(new Date() - new Date(req.session.data.lastActivity) < 5 * 60 * 1000) {
req.session.data.lastActivity = new Date(); req.session.data.lastActivity = new Date().toString();
} else { } else {
req.session.data.login = false; req.session.data.login = false;
} }
@ -57,7 +57,7 @@ var constructor = function(db) {
} }
if(!err && match == true) { if(!err && match == true) {
req.session.data.login = true; req.session.data.login = true;
req.session.data.lastActivity = new Date(); req.session.data.lastActivity = new Date().toString();
res.send(200, JSON.stringify({ res.send(200, JSON.stringify({
"success": true "success": true
})); }));