Skip to content

fix: ensure session is persisted before OAuth callback returns#220

Open
lwzbwtj wants to merge 1 commit intoalgora-io:mainfrom
lwzbwtj:fix/oauth-race-condition
Open

fix: ensure session is persisted before OAuth callback returns#220
lwzbwtj wants to merge 1 commit intoalgora-io:mainfrom
lwzbwtj:fix/oauth-race-condition

Conversation

@lwzbwtj
Copy link

@lwzbwtj lwzbwtj commented Mar 20, 2026

Description

Fixes race condition where frontend checks session before cookie is set.

Problem

OAuth callback completes successfully on backend, but frontend request may hit
a race condition or stale session state during redirect, causing 500 error.
After refreshing the page, the session works correctly.

Solution

Explicitly call configure_session(persist: true) after setting session values
to ensure the session cookie is properly saved before the response is sent
to the client.

Changes

  • Modified put_current_user/2 in UserAuth controller
  • Added explicit session persistence to prevent race condition

Checklist

  • I have tested this change locally
  • This fix addresses the reported issue

Closes #186

Fixes race condition where frontend checks session before cookie is set.

The issue: OAuth callback completes successfully on backend, but
frontend request may hit a race condition or stale session state
during redirect, causing 500 error.

The fix: Explicitly call configure_session(persist: true) after setting
session values to ensure the session cookie is properly saved before
the response is sent to the client.

Closes algora-io#186
@CLAassistant
Copy link

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When I login, page shows me 500 always

2 participants