Skip to content

feat: handle replayed OIDC callbacks and improve auth error handling - #325

Merged
vinit-truefoundry merged 5 commits into
mainfrom
bugfix/AGE-1830/on-clicking-go-back-from-settings-or-chat-it-sends-to-login-failed
Aug 19, 2026
Merged

feat: handle replayed OIDC callbacks and improve auth error handling#325
vinit-truefoundry merged 5 commits into
mainfrom
bugfix/AGE-1830/on-clicking-go-back-from-settings-or-chat-it-sends-to-login-failed

Conversation

@vinit-truefoundry

@vinit-truefoundry vinit-truefoundry commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Changes OIDC callback redirect logic and frontend auth gating; scoped to replay/stale-error handling with tests, but touches security-sensitive login flows.

Overview
Fixes the case where browser Back after a successful OIDC login replays the callback URL and leaves ?error=login_failed on the address bar even though the user is still authenticated.

Backend (/callback): Before redirecting to /?error=…, the handler now checks an existing session via resolveAuthUser. On state mismatch, IdP error, or failed code exchange, authenticated users are redirected home (or return_to) instead of the error landing.

Frontend: Session probing runs even when ?error= is present, so a valid session is detected instead of skipping the probe. The auth error screen only appears when the session is unauthenticated (shouldShowAuthErrorScreen). After authentication, stale error query params are stripped with history.replaceState via stripAuthErrorSearch.

Unit tests cover the new URL helpers and callback replay paths.

Reviewed by Cursor Bugbot for commit 711ad3c. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 711ad3c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5afb6d1. Configure here.

Comment thread packages/trueforge/src/apis/auth.ts
Comment thread packages/frontend/src/App.tsx Outdated
vinit-truefoundry and others added 2 commits August 19, 2026 16:48
Co-authored-by: sayan-truefoundry <136362719+sayan-truefoundry@users.noreply.github.com>
@vinit-truefoundry
vinit-truefoundry enabled auto-merge (squash) August 19, 2026 11:19
@vinit-truefoundry
vinit-truefoundry merged commit 2c3278e into main Aug 19, 2026
9 checks passed
@vinit-truefoundry
vinit-truefoundry deleted the bugfix/AGE-1830/on-clicking-go-back-from-settings-or-chat-it-sends-to-login-failed branch August 19, 2026 11:58
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.

2 participants