|
|
@ -59,14 +59,18 @@ Core.getSession = function (Sessions, key) {
|
|
|
|
return user;
|
|
|
|
return user;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Core.expireSession = function (Sessions, key, cb) {
|
|
|
|
Core.expireSession = function (Sessions, safeKey) {
|
|
|
|
|
|
|
|
var session = Sessions[safeKey];
|
|
|
|
|
|
|
|
if (!session) { return; }
|
|
|
|
|
|
|
|
if (session.blobstage) {
|
|
|
|
|
|
|
|
session.blobstage.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delete Sessions[safeKey];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Core.expireSessionAsync = function (Env, safeKey, cb) {
|
|
|
|
setTimeout(function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
var session = Sessions[key];
|
|
|
|
Core.expireSession(Sessions, safeKey);
|
|
|
|
if (!session) { return; }
|
|
|
|
|
|
|
|
if (session.blobstage) {
|
|
|
|
|
|
|
|
session.blobstage.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delete Sessions[key];
|
|
|
|
|
|
|
|
cb(void 0, 'OK');
|
|
|
|
cb(void 0, 'OK');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -77,10 +81,10 @@ var isTooOld = function (time, now) {
|
|
|
|
|
|
|
|
|
|
|
|
Core.expireSessions = function (Sessions) {
|
|
|
|
Core.expireSessions = function (Sessions) {
|
|
|
|
var now = +new Date();
|
|
|
|
var now = +new Date();
|
|
|
|
Object.keys(Sessions).forEach(function (key) {
|
|
|
|
Object.keys(Sessions).forEach(function (safeKey) {
|
|
|
|
var session = Sessions[key];
|
|
|
|
var session = Sessions[safeKey];
|
|
|
|
if (session && isTooOld(session.atime, now)) {
|
|
|
|
if (session && isTooOld(session.atime, now)) {
|
|
|
|
Core.expireSession(Sessions, key);
|
|
|
|
Core.expireSession(Sessions, safeKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|