From 020f0b832222681e67eb7f594f96ffb5a357e0be Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 22 Feb 2021 11:18:30 -0500 Subject: [PATCH] fix: session not persisting to database in some scenarios In some edge cases (e.g. SSO plugin redirecting the user immediately), with modern browsers, the request is never "completed" for speed. This causes a condition where the session object never persists to the database, even though it has changed. This added line forces a db persist on a successful login. Context: https://github.com/expressjs/session/pull/484 --- src/controllers/authentication.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 8dcffd086d..c2a13fa792 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -352,6 +352,7 @@ authenticationController.onSuccessfulLogin = async function (req, uid) { version: req.useragent.version, }); await Promise.all([ + new Promise(resolve => req.session.save(resolve)), user.auth.addSession(uid, req.sessionID), user.updateLastOnlineTime(uid), user.updateOnlineUsers(uid),