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

[SDK-3666] Support multiple providers #416

Merged
merged 3 commits into from
Oct 12, 2022
Merged

[SDK-3666] Support multiple providers #416

merged 3 commits into from
Oct 12, 2022

Conversation

ewanharris
Copy link
Contributor

Description

This adds support for multiple instances of Auth0Provider being used within an application, this is achieved by providing a context parameter (created using React.createContext) to the Auth0Provider, this same context can then be provided to useAuth0, withAuth0, and withAuthenticationRequired in order to access the authentication state and methods associated with that instance of Auth0Provider.

The choice to accept the context in the helpers was made to avoid users having to maintain their own versions of these that may deviate from the internal version. Whilst for useAuth0 and withAuth0 this was unlikely due to their simple-ness, withAuthenticationRequired is more complex so I figured that it was worth it.

References

#290

Testing

Describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests.

Also include details of the environment this PR was developed in (language/platform/browser version).

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

Alongside this I've also produced a React version of the account linking sample to demonstrate/test this work. In order to run it check out this branch, build the repo and run npm link in this repo, and then npm link @auth0/auth0-react in the sample.

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 the default branch

Copy link
Contributor

@adamjmcgrath adamjmcgrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a couple of things

__tests__/use-auth.test.tsx Show resolved Hide resolved
__tests__/with-authentication-required.test.tsx Outdated Show resolved Hide resolved
@adamjmcgrath
Copy link
Contributor

(optional) also might be nice to do the nested Auth0Provider test in auth-provider.test.tsx

@ewanharris ewanharris changed the title Support multiple providers [SDK-3666] Support multiple providers Oct 12, 2022
@ewanharris ewanharris merged commit edcdb5a into master Oct 12, 2022
@ewanharris ewanharris deleted the SDK-3666 branch October 12, 2022 09:10
@adamjmcgrath adamjmcgrath mentioned this pull request Oct 12, 2022
@ewanharris ewanharris linked an issue Oct 28, 2022 that may be closed by this pull request
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.

Support for multiple clients/contexts
2 participants