Clear auth params from URL parameters when redirectCallback fails #832
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.
Description
Currently, auth params are kept in the URL when logging in fails (i.e., the handle redirect callback fails). Even refreshing the page afterwards won't clear the auth params. Changing this behavior application-side is also difficult, as there is no callback to hook into and clear the auth codes manually.
This PR changes the
onRedirectCallback
to be called regardless of whether the handle redirect callback succeeds or not. If it fails, no app state nor user is passed to the callback. This works with the existing function signature.It does change the semantics slightly, though. If
onRedirectCallback
throws an exception, it won't be caught anymore (as it would be right now). Also,onRedirectCallback
being called doesn't in itself imply that handling the callback succeeded. The application will need to look at the parameter values and the overall hook state to determine whether logging in succeeded or not.Another alternative would be to introduce a second callback, something along the lines of
onRedirectCallbackError
that is called with the error. This would make theonRedirectCallback
behavior stay exactly the same by preserving error catching and when it's called. On the other hand, it would be a larger change in the AuthProvider signature (hence the simpler variant here).Testing
Checklist