Skip to content

Commit

Permalink
DT-5972 ensure logout completed before delete session
Browse files Browse the repository at this point in the history
  • Loading branch information
sharhio committed Nov 8, 2023
1 parent 928c436 commit 8f7da40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 3 additions & 5 deletions server/auth/Strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,10 @@ OICStrategy.prototype.refresh = function (req) {
})
.catch(err => {
console.error('Error refreshing tokens', err);
if (req.session) {
req.logout(function (err) {
if (err) { return next(err); }
});
req.logout(function (err) {
if (err) { return next(err); }
req.session.destroy();
}
});
this.fail(err);
});
};
Expand Down
7 changes: 3 additions & 4 deletions server/auth/openidConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ function setUpOIDC(app, port, indexPath, hostnames, paths, localPort) {
if (
req.isAuthenticated() &&
req.session &&
token &&
token.refresh_token &&
dayjs().unix() >= token.expires_at
token?.refresh_token &&
dayjs().unix() >= token?.expires_at
) {
const userData = JSON.stringify(req?.user?.data);
let oidcStrategyName = '';
Expand All @@ -172,7 +171,7 @@ function setUpOIDC(app, port, indexPath, hostnames, paths, localPort) {
return passport.authenticate(oidcStrategyName, {
refresh: true,
successReturnToOrRedirect: `/${req.path}`,
failureRedirect: `/${req.path}`,
failureRedirect: '/',
})(req, res, next);
}
return next();
Expand Down

0 comments on commit 8f7da40

Please sign in to comment.