important
This is a contributors guide and NOT a user guide. Please visit these docs if you are using or evaluating SuperTokens.
Use configurable callbacks to redirect on claim validation success/failure
Status
This is just a proposal so far, it hasn't been accepted and needs further discussion.
- Status:
- proposed
- Deciders:
- rishabhpoddar, porcellus
- Proposed by:
- porcellus
- Created:
- 2022-11-28
#
Context and Problem StatementApps have to handle redirection if a claim fails and also handle redirecting back if necessary. E.g.:
- While using a custom 2FA claim, the app has to check if there is a validation error for the claim in the
invalidClaims
array and handle redirection. - On the 2FA page, the app has to check if that validation error disappeared (so the user successfully logged in using 2FA)
#
Considered Options- Recommend creating wrapper components
- Add a callback that returns a react component to render on failure
- Add callbacks (onFailure, onSuccess) that returns a string (or undefined) we can redirect to
- Add a separate component that handles these checks/mapping
#
Decision OutcomeAdd callbacks (onFailure, onSuccess) that returns a string (or undefined) we can redirect to.
We've also decided to add a default access denied screen where we can redirect in case of an unhandled claim failure.
- this is triggered when a claim fails without a defined onFailure CB
- this could get: overridden as a component, overridden with getRedirectToPath in the session init
#
Pros and Cons of the Options#
Recommend creating wrapper components#
Add a callback that returns a react component to render on failure#
Add callbacks (onFailure, onSuccess) that returns a string (or undefined) we can redirect toIn this case we embed the contact info in the link which enables us to show the sign in screen but we can delay the consume (on the FE) until the validation info is fetched.