Skip to content

Redirect when a sign-in flow completes on its first step#4

Draft
madurangasiriwardena wants to merge 1 commit into
thunder-id:mainfrom
madurangasiriwardena:feature/session-poc-2
Draft

Redirect when a sign-in flow completes on its first step#4
madurangasiriwardena wants to merge 1 commit into
thunder-id:mainfrom
madurangasiriwardena:feature/session-poc-2

Conversation

@madurangasiriwardena

Copy link
Copy Markdown
Member

Purpose

Fix the login gate hanging on a perpetual loading spinner when an authentication flow completes on its very first /flow/execute step — i.e. when the backend returns flowStatus: COMPLETE immediately, before any UI components are rendered (for example, when a reused browser SSO session lets the flow finish without a credential prompt).

In v2 SignIn, terminal flow statuses (Complete / Error) were handled only in the submission path (handleSubmit), not on the initial flow load (initializeFlow). On an initial COMPLETE response there are no components to render, so the initialize path fell through and the UI stayed on CircularProgress forever instead of redirecting to the callback.

This is a general client-side correctness fix: any flow that completes (or errors) on its first step is now finished properly. It is self-contained — no dependency on any backend feature, and no behavior change for existing flows that begin with a prompt (the new branch simply isn't hit until a flow returns COMPLETE on the first step).

Approach

  • Extracted the existing terminal-response handling (the inline Complete and Error blocks in handleSubmit) into a shared async helper, handleTerminalResponse(response):
    • Error → clear flow state, surface the error, throw so the caller's catch propagates it to BaseSignIn.
    • Complete → resolve the redirect target (redirectUrl / redirect_uri, falling back to afterSignInUrl), clear OAuth/flow storage, fire onSuccess, and redirect. Returns true so callers stop processing.
  • Called the helper in initializeFlow right after handleRedirection (the actual bug fix), and replaced the duplicated inline blocks in handleSubmit with the same call (no behavior change to that path).
  • Behavior, storage cleanup, and redirect semantics are preserved exactly; only the call site coverage and de-duplication changed.

Related Issues

  • N/A

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

The v2 SignIn handled terminal flow statuses (Complete/Error) only after a
submission, not on the initial flow load. When a flow completes on its first
step — e.g. a reused browser SSO session lets the backend return COMPLETE
immediately with no UI components — the gate fell through with no components
and spun on a loader forever.

Extract the terminal-response handling into a shared helper and run it on the
initial load (initializeFlow) as well as after a submission (handleSubmit), so
the flow redirects to the callback instead of hanging.
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d74e9879-f946-4b84-8902-4b01e6d66c15

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant