Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra options to withAuthenticationRequired #41

Merged
merged 1 commit into from
Jun 17, 2020

Conversation

adamjmcgrath
Copy link
Contributor

@adamjmcgrath adamjmcgrath commented Jun 17, 2020

Description

There are some cases where just the location.pathname is not enough information for the user to be returned to the url they were redirected to the login page from. eg hashrouting

Allow the returnTo param to be customised as a string or a method to handle these cases, eg for hash routing:

// A typical hash route will look like http://localhost:3000/#/users
withAuthenticationRequired(Users, {
  returnTo: () => window.location.hash.substr(1) // '/users'
})

Also allow the user to pass RedirectLoginOptions to loginWithRedirect in case they want to add additional appState

References

auth0-samples/auth0-vue-samples#100 (A Vue example, but the same applies to React)
https://reacttraining.com/react-router/web/api/HashRouter

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@adamjmcgrath adamjmcgrath added the medium This PR may require moderate effort to action, or contains many changes to review label Jun 17, 2020
@adamjmcgrath adamjmcgrath requested a review from a team June 17, 2020 15:14
@adamjmcgrath adamjmcgrath added the CH: Breaking Change PR contains breaking changes without a major version bump label Jun 17, 2020
@adamjmcgrath adamjmcgrath merged commit b9f8063 into master Jun 17, 2020
@adamjmcgrath adamjmcgrath deleted the with-auth-required-opts branch June 17, 2020 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CH: Breaking Change PR contains breaking changes without a major version bump medium This PR may require moderate effort to action, or contains many changes to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants