Skip to content

Commit

Permalink
Destroy session completely (#1201)
Browse files Browse the repository at this point in the history
* When logging out destroy the current session not only in the User model but also the session store
* Currently `maxAge` is set to expire at browser session end... client side cookie goes away at browser private data clear but sessionId in the store sticks around for quite some time. Logging out means destroy it and login again later.
* Leaving the old `delete` in for extra cautiousness... not really needed imho as it throws an error outside of it after `destroy()`

Related to #604

Auto-merge
  • Loading branch information
Martii authored Oct 25, 2017
1 parent ff570dc commit f4bd642
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libs/modifySessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ exports.add = function (aReq, aUser, aCallback) {
}
};

// Remove a session id from the user model
// Remove a session id from the user model **and** the session store
exports.remove = function (aReq, aUser, aCallback) {
var pos = aUser && aUser.sessionIds ?
aUser.sessionIds.indexOf(aReq.sessionID) : -1;

delete aReq.session.user;
if (aReq.session.destroy) {
aReq.session.destroy();
} else { // TODO: Remove conditional and this fallback when satisifed
delete aReq.session.user;
}

if (pos > -1) {
aUser.sessionIds.splice(pos, 1);
Expand Down

0 comments on commit f4bd642

Please sign in to comment.