fix: protected route should work without any props #218
+112
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request introduces improvements to the
ProtectedRoutecomponent in@asgardeo/react-router, enhancing its flexibility and developer experience. The main changes allowProtectedRouteto function without requiring props, add support for custom sign-in logic and parameters, and improve platform-specific handling in the Asgardeo React SDK.ProtectedRoute enhancements:
ProtectedRoutecomponent now works without requiring any props, simplifying usage for default authentication flows.ProtectedRoute:onSignInfor custom sign-in logic andsignInOptionsfor passing additional authorization parameters. This allows developers to override the default sign-in behavior and customize authentication requests. [1] [2]ProtectedRoutehas been updated to handle cases where a sign-in URL is available, invoke custom sign-in handlers, or use merged sign-in options. Improved error handling for misconfiguration is also included.SDK/platform improvements:
AsgardeoReactClient, embedded sign-in flow for Asgardeo V2 now checks forflowIdorapplicationIdin the provided options before triggering the flow, ensuring more accurate platform handling.AsgardeoProvider, user claim extraction logic is updated to correctly handle Asgardeo V2 platform, improving compatibility with the latest platform features.API exports:
navigateutility is now re-exported from@asgardeo/browserin the React SDK, making it available for routing and navigation needs.Related Issues
@asgardeo/react&@asgardeo/nextjs#81Related PRs
Checklist
Security checks