fix: tests, handle no sessions

v1.18.x
Barış Soner Uşaklı 5 years ago
parent a0d76ff0a6
commit 8bf980cb63

@ -350,10 +350,12 @@ authenticationController.onSuccessfulLogin = async function (req, uid) {
});
await Promise.all([
user.auth.addSession(uid, req.sessionID),
(uid > 0) ? db.setObjectField('uid:' + uid + ':sessionUUID:sessionId', uuid, req.sessionID) : null,
user.updateLastOnlineTime(uid),
user.updateOnlineUsers(uid),
]);
if (uid > 0) {
await db.setObjectField('uid:' + uid + ':sessionUUID:sessionId', uuid, req.sessionID);
}
// Force session check for all connected socket.io clients with the same session id
sockets.in('sess_' + req.sessionID).emit('checkSession', uid);

@ -82,6 +82,9 @@ module.exports = function (User) {
async function cleanExpiredSessions(uid) {
const uuidMapping = await db.getObject('uid:' + uid + ':sessionUUID:sessionId');
if (!uuidMapping) {
return;
}
const expiredUUIDs = [];
const expiredSids = [];
await Promise.all(Object.keys(uuidMapping).map(async (uuid) => {

Loading…
Cancel
Save