implement EXPIRE_SESSION rpc

pull/1/head
ansuz 7 years ago
parent 9f6ecea5d9
commit 63fd7b4dde

@ -113,15 +113,21 @@ var isTooOld = function (time, now) {
return (now - time) > 300000; return (now - time) > 300000;
}; };
var expireSessions = function (Sessions) { var expireSession = function (Sessions, key) {
var now = +new Date();
Object.keys(Sessions).forEach(function (key) {
var session = Sessions[key]; var session = Sessions[key];
if (isTooOld(Sessions[key].atime, now)) { if (!session) { return; }
if (session.blobstage) { if (session.blobstage) {
session.blobstage.close(); session.blobstage.close();
} }
delete Sessions[key]; delete Sessions[key];
};
var expireSessions = function (Sessions) {
var now = +new Date();
Object.keys(Sessions).forEach(function (key) {
var session = Sessions[key];
if (session && isTooOld(session.atime, now)) {
expireSession(Sessions, key);
} }
}); });
}; };
@ -846,6 +852,7 @@ var isAuthenticatedCall = function (call) {
'GET_LIMIT', 'GET_LIMIT',
'UPLOAD_COMPLETE', 'UPLOAD_COMPLETE',
'UPLOAD_CANCEL', 'UPLOAD_CANCEL',
'EXPIRE_SESSION',
].indexOf(call) !== -1; ].indexOf(call) !== -1;
}; };
@ -1046,7 +1053,11 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function)
} }
Respond(void 0, dict); Respond(void 0, dict);
}); });
case 'EXPIRE_SESSION':
return void setTimeout(function () {
expireSession(Sessions, safeKey);
Respond(void 0, "OK");
});
// restricted to privileged users... // restricted to privileged users...
case 'UPLOAD': case 'UPLOAD':
if (!privileged) { return deny(); } if (!privileged) { return deny(); }

Loading…
Cancel
Save