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-1580] [SDK-1581] Add withAuth and withLoginRequired #7

Merged
merged 1 commit into from
May 7, 2020

Conversation

adamjmcgrath
Copy link
Contributor

@adamjmcgrath adamjmcgrath commented May 7, 2020

Description

Adds higher order components:

  • withAuth for wrapping class components
  • withLoginRequired for protecting components (usually routes)

Testing

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

Checklist

  • 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 May 7, 2020
@adamjmcgrath adamjmcgrath requested a review from a team May 7, 2020 15:22
@adamjmcgrath adamjmcgrath added the CH: Added PR is adding feature or functionality label May 7, 2020
@@ -28,7 +28,7 @@ Auth0 SDK for React Applications.
## Installation

```bash
npm install react react-dom @auth0/auth0-spa-js auth0/auth0-react
npm install @auth0/auth0-spa-js auth0/auth0-react
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we didn't really need to tell users to install react

Copy link
Contributor

Choose a reason for hiding this comment

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

Could removing this though lead to the assumption that we install react for them as a dependency? How would they know that without diving into package.json?

Perhaps we don't need to include it in the installation command but we could cover that with a quick sentence prior to this which says something to the effect of "This SDK should be installed into a React application". The clue is in the name. However, I think we should be clear.

@@ -20,7 +20,6 @@
"types": "dist/index.d.ts",
"module": "dist/auth0-react.esm.js",
"scripts": {
"prepare": "rollup -c --environment NODE_ENV:production",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't work with react because of facebook/react#14257

@adamjmcgrath adamjmcgrath changed the title Add withAuth and withLoginProvided [SDK-1580] [SDK-1581] Add withAuth and withLoginProvided May 7, 2020
Copy link
Contributor

@stevehobbsdev stevehobbsdev left a comment

Choose a reason for hiding this comment

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

Couple of things to think about which I don't want to hold up the EA release, but could be talked about before we head to beta.

@@ -28,7 +28,7 @@ Auth0 SDK for React Applications.
## Installation

```bash
npm install react react-dom @auth0/auth0-spa-js auth0/auth0-react
npm install @auth0/auth0-spa-js auth0/auth0-react
Copy link
Contributor

Choose a reason for hiding this comment

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

Could removing this though lead to the assumption that we install react for them as a dependency? How would they know that without diving into package.json?

Perhaps we don't need to include it in the installation command but we could cover that with a quick sentence prior to this which says something to the effect of "This SDK should be installed into a React application". The clue is in the name. However, I think we should be clear.

* Get an access token.
*/
getToken: (
options?: GetTokenSilentlyOptions
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're surfacing options types from SPA JS here are we still able to generate documentation as if they were part of this library?

Surfacing these options couples us tighter to the underlying SDK, which should be somewhat transparent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but I think we'd need to bundle a version of spa js with the library if we don't do this (which we could do?)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's worth a further discussion but all I'm talking about really is wrapping those SDK types with types native to the React library rather than exposing GetTokenSilentlyOptions.

We would just have GetTokenOptions for example, which internally maps to GetTokenSilentlyOptions. Means the SDK isn't as exposed but also we can generate the right doctypes and not force the user to go elsewhere to figure out what properties they can specify and what their docs are.

@adamjmcgrath adamjmcgrath merged commit 877910d into master May 7, 2020
@stevehobbsdev stevehobbsdev deleted the higher-order-components branch May 7, 2020 16:59
@adamjmcgrath adamjmcgrath changed the title [SDK-1580] [SDK-1581] Add withAuth and withLoginProvided [SDK-1580] [SDK-1581] Add withAuth and withLoginRequired May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CH: Added PR is adding feature or functionality 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.

None yet

2 participants