Skip to content

Conversation

@thiva-k
Copy link
Contributor

@thiva-k thiva-k commented Nov 25, 2025

This pull request refactors the SignIn component to improve flow state management, error handling, and URL parameter cleanup for authentication flows. The changes introduce several utility functions to centralize logic for handling flow IDs, session data, and OAuth-related parameters, resulting in more robust and maintainable code. Error handling is now more consistent, and the component better cleans up stale or invalid flow state, ensuring a smoother user experience.

Flow State Management & Cleanup

  • Added utility functions (setFlowId, clearFlowState, getUrlParams, handleSessionDataKey, resolveFlowId) to centralize and synchronize flow ID and session data between state and sessionStorage. These functions also clean up stale or invalid flow state and related URL parameters, preventing issues with incomplete or expired authentication flows.
  • Updated initialization and submission logic to use these utilities, ensuring that flow IDs are correctly set, cleaned up, and removed from the URL when appropriate. This also includes handling stale flow IDs and properly resetting state when flows are invalidated. [1] [2] [3] [4] [5]

Error Handling Improvements

  • Centralized error handling using the new setError function, which sets error state, triggers the onError callback, and ensures errors are displayed in the UI. OAuth errors and flow errors now trigger proper cleanup and user feedback. [1] [2] [3]

OAuth & Flow URL Parameter Cleanup

  • Added dedicated functions to clean up OAuth and flow-related URL parameters (cleanupOAuthUrlParams, cleanupFlowUrlParams) after processing, preventing accidental reuse of expired parameters and improving security. [1] [2]

Robust OAuth Callback Handling

  • Improved OAuth callback processing to handle errors first, resolve flow IDs from multiple sources, and ensure proper state synchronization and cleanup in case of failures. [1] [2]

Consistent Error Messaging

  • Standardized error codes and messages in thrown errors, replacing ad-hoc error codes with 'SIGN_IN_ERROR' for easier debugging and monitoring. [1] [2]

These changes collectively make the authentication flow more reliable, easier to debug, and safer for users.

@thiva-k thiva-k force-pushed the fix-sdk-err-handling branch from 03eee3c to 31deeec Compare November 26, 2025 09:00
@thiva-k thiva-k force-pushed the fix-sdk-err-handling branch from cafece9 to a1a2bae Compare November 26, 2025 09:52
@thiva-k thiva-k force-pushed the fix-sdk-err-handling branch from 7bc7c83 to 4ff39c8 Compare November 27, 2025 10:51
@asgardeo-github-bot
Copy link

🦋 Changeset detected

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

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

@darshanasbg darshanasbg merged commit 4e9d923 into asgardeo:main Nov 27, 2025
3 of 6 checks passed
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.

4 participants