🔧 feat: Implement custom logout redirect handling and enhance OpenID auto-redirect logic

This commit is contained in:
Ruben Talstra 2025-03-10 11:52:36 +01:00
parent a2f953460b
commit 17b0f35f93
No known key found for this signature in database
GPG key ID: 2A5A7174A60F3BEA
6 changed files with 82 additions and 127 deletions

View file

@ -22,13 +22,6 @@ const oauthHandler = async (req, res) => {
return;
}
await setAuthTokens(req.user._id, res);
// On successful login, let's clear any openid redirect flags
res.cookie('successful_login', 'true', {
maxAge: 1000, // very short-lived, just for client-side detection
httpOnly: false // client needs to read this
});
res.redirect(domains.client);
} catch (err) {
logger.error('Error in setting authentication tokens:', err);
@ -38,9 +31,9 @@ const oauthHandler = async (req, res) => {
router.get('/error', (req, res) => {
// A single error message is pushed by passport when authentication fails.
logger.error('Error in OAuth authentication:', { message: req.session.messages.pop() });
// Redirect to login page with auth_failed parameter to prevent infinite redirect loops
res.redirect(`${domains.client}/login?auth_failed=true`);
res.redirect(`${domains.client}/login?redirect=false`);
});
/**