Skip to content

Commit

Permalink
fix: session not persisting to database in some scenarios
Browse files Browse the repository at this point in the history
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: expressjs/session#484
  • Loading branch information
julianlam committed Feb 22, 2021
1 parent 504fd10 commit 020f0b8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/controllers/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 020f0b8

Please sign in to comment.