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 API user signup #5

Closed
wants to merge 10 commits into from
Closed

Add API user signup #5

wants to merge 10 commits into from

Conversation

binh-dam-ibigroup
Copy link
Contributor

This PR adds a mechanism for a new API user to sign up from the OTP-admin-ui app:

  • Use react-bootstrap 1.0.1 and its CSS,
  • Load user data in MyLayout so it can be passed to child components/pages,
  • Display a verify email screen from MyLayout if email is not verified in Auth0,
  • Adds a component ApiUserSetup where new API users enter and save their info
  • The list of OTP users is shown only for admins.

Retrieving and modifying API user data is not implemented (yet).

To test: you need ibi-group/otp-middleware#32.

There are still rough edges from copy-pasting the user fetching code from OTP-RR, so let me know for things that need to be adjusted.

@vercel
Copy link

vercel bot commented Jul 9, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/ibi-group/otp-admin-ui/2eqemagps
✅ Preview: https://otp-admin-ui-git-add-apiuser-signup.ibi-group.vercel.app

@binh-dam-ibigroup binh-dam-ibigroup changed the title Add API user signup WIP: Add API user signup Jul 9, 2020
@binh-dam-ibigroup binh-dam-ibigroup changed the title WIP: Add API user signup Add API user signup Jul 9, 2020
}
}

async componentDidUpdate () {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like all this auth0 stuff shouldn't be in a file dedicated to layouts. A better place would probably be in the pages/_app file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately that cannot be in pages/_app.js because the <Auth0Provider> component is there and provides the auth props to all the children. It can be in a component between <Auth0Provider> and <Layout>.

Copy link
Contributor

Choose a reason for hiding this comment

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

@binh-dam-ibigroup, see my commits in the demo branch to reorganize some things. It contains an example of how I think some of this stuff should work.

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 defer to a discussion we may need to have (#10) regarding how nextjs recommends fetching data.

@@ -15,10 +16,22 @@ export default function Index () {
</div>
)
}

if (!isUserFetched) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the user is never fetched, this will continuously show this loading message. There needs to be some logic for what happens when a user is unable to login or doesn't have a login in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've fixed this (somewhat) in a recent commit. The issue appears to be that isLoading from userAuth is is not working: sandrinodimattia/use-auth0-hooks#14

Also, as @binh-dam-ibigroup mentioned elsewhere, we should probably migrate to https://github.com/auth0/auth0-react during next sprint at some point

* @param {string} method The HTTP method to execute.
* @param {*} options Extra options to pass to fetch.
*/
export async function secureFetch (url, accessToken, apiKey, method = 'get', options = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be merged with the secureFetch method contained in #6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And the snake is biting its tail...

@evansiroky evansiroky mentioned this pull request Jul 11, 2020
Copy link
Contributor

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

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

Travis builds are failing. Also see comments.

Also move email verif screen logic to index.js
Copy link
Contributor

@landonreed landonreed left a comment

Choose a reason for hiding this comment

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

Leaving a review off for now, but this is just to say that https://github.com/ibi-group/otp-admin-ui/tree/demo contains changes that reflect my thinking on how things could be organized. Perhaps I'll just create a PR into this and make my approval contingent upon that merge.

@binh-dam-ibigroup
Copy link
Contributor Author

Closing in favor of #8 and #9

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.

3 participants