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

WIP Update user registration flow #168

Merged
merged 13 commits into from
Apr 18, 2021
Merged

Conversation

pdotsani
Copy link
Contributor

@pdotsani pdotsani commented Nov 21, 2020

What type of PR is this? (check all applicable)

  • ♻️ Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 🎨 Enhancement
  • 📝 Documentation Update
  • 🔖 Release
  • 🚩 Other

Context

This PR closes issue #161

Screenshots/Recordings (if there are UI changes)

Placeholder example: ![screenshot of new resource page](https://user-images.githubusercontent.com/43/23.png)

Note: you can upload a screenshot onto your PR and put it here.

Implementation Details - what was your thought process as you changed the code?

  • Update the POST request when a user registers to hit POST /api/v1/auth/registration/
  • Remove the first name and last name fields
  • Change the login endpoint to be POST /api/v1/auth/login/
  • Change the logout endpoint to be POST api/v1/auth/logout
  • Create a api/v1/auth/registration/verify-email?key={KEY} page that upon load, makes a POST request to /verify-email and passes in the key from the params in the URL

Related Tickets & Documents (Optional)

This relates to #161

Added tests?

  • 👍 yes (updated tests)
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation (readme.md or contributing.md)?

  • 📜 readme.md
  • 📜 contributing.md
  • 🙅 no documentation needed
  • 🙋 I'd like someone to help write documentation, and will file a new issue for it

@pdotsani pdotsani changed the title Update user registration flow WIP Update user registration flow Nov 21, 2020
@stale
Copy link

stale bot commented Dec 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 21, 2020
@stale stale bot closed this Dec 28, 2020
@lpatmo lpatmo reopened this Dec 29, 2020
@stale stale bot removed the stale label Dec 29, 2020
@stale
Copy link

stale bot commented Jan 28, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 28, 2021
@BethanyG
Copy link
Member

@lpatmo @pdotsani -- is this still a WIP? Should we be removing the stale tag?

@stale stale bot removed the stale label Jan 28, 2021
@pdotsani
Copy link
Contributor Author

Yupp. Still WIP. We're still trying to find a time to get together to finish it.

@lpatmo
Copy link
Member

lpatmo commented Jan 31, 2021

@pdotsani @peoray Thanks for working on this this morning! Re: the bugs that you ran into...

DoesNotExist at /api/v1/auth/login/ EmailAddress matching query does not exist. seems to be and api issue. I tried using preloaded user data generated by script.

I'm not sure that the preloaded user data generated by the script should work against that endpoint; you should be using a new user you registered.

Verification email is not being sent. This happens when I try to login with existing user credentials and when I try to create new ones.

This is because in dev, the registration email appears in the logs when you run docker-compose up (mailhog). You won't get a real email.

=========

This is the process that worked for me:

  1. In your backend repo, run docker-compose up (without the -d flag so that you're not hiding the logs)

  2. In SignupForm.js, change the POST URL to .post('http://localhost:8000/api/v1/auth/registration/', data). Make sure it's http:localhost:8000, not https.

(In the meantime, I'll look into figuring out how we can sidestep hardcoding this, so that it's automatically http://localhost:8000 if someone is running this locally and https://api-staging.codebuddies.org when this is deployed.)

  1. On the frontend repo, run npm run start to start the app. Go to https://localhost:3000/signup and register a new user.

Make sure the password is something not too common; otherwise you'll get an error. fwiw, I used codebuddies as my fake password and that worked fine.

image

After you successfully register a new user, you'll be redirected to this page:
image

And the logs will look like this:
image

  1. Next, you can log out. You'll see this screen:
    image
    image

  2. When you try to log in, you'll see "Email is not verified":

image

If you remember the logs, they pointed to a URL that said:

http://localhost:8000/api/v1/auth/registration/verify-email/?key=MTI:1l624W:Wa-4hXDvgMRyRtfdy9C06oBR9rU

We can fix the hostname in the BE later (I believe there is a ticket for that on github.com/codebuddies/backend), but https://localhost:3000/api/v1/auth/registration/verify-email/?key={KEY} is the page we need to create on the FE side, and it needs to make a POST request to the http://localhost:8000/api/v1/auth/registration/verify-email/ endpoint.
image

For example, if I paste my key into my BE app and click on the POST button:
image
image

...that's a successful response. :)

Let me know if you need more screenshots/if any part of this doesn't make sense!

@pdotsani pdotsani force-pushed the feature/update-registration-flow branch 4 times, most recently from cc6ded1 to df9fa10 Compare February 13, 2021 19:48
@pdotsani pdotsani marked this pull request as ready for review February 13, 2021 19:49
@lpatmo
Copy link
Member

lpatmo commented Feb 16, 2021

@pdotsani Thank you for updating the tests and the error messages! :) I think it's fine to comment out the lines in the test that aren't relevant anymore (e.g. the first and last name).

Looks like this is the main TODO that remains, since logout is taken care of via localStorage.clear('tokens');:

  • Create a api/v1/auth/registration/verify-email?key={KEY} page that upon load, makes a POST request to /verify-email and passes in the key from the params in the URL

Can work on making that route if you want help!

@pdotsani
Copy link
Contributor Author

@pdotsani Thank you for updating the tests and the error messages! :) I think it's fine to comment out the lines in the test that aren't relevant anymore (e.g. the first and last name).

Looks like this is the main TODO that remains, since logout is taken care of via localStorage.clear('tokens');:

  • Create a api/v1/auth/registration/verify-email?key={KEY} page that upon load, makes a POST request to /verify-email and passes in the key from the params in the URL

Can work on making that route if you want help!

@lpatmo Ah ok. Didn't have enough time to get to this last week. Should be finishing up in the week or so.

@lpatmo
Copy link
Member

lpatmo commented Feb 17, 2021

@pdotsani Thank you!!

@pdotsani
Copy link
Contributor Author

Thanks for the help @lpatmo. The new view and post request are working, and should be ready for review. The only additional change needed is that the url on the verification email needs to be updated to the client (localhost:3000 on local development).

src/components/Auth/VerifyEmail.js Outdated Show resolved Hide resolved
src/components/Auth/SignUpForm.js Show resolved Hide resolved
src/components/Auth/VerifyEmail.js Outdated Show resolved Hide resolved
@lpatmo
Copy link
Member

lpatmo commented Mar 14, 2021

@pdotsani Sweet, thank you so much! I added a couple of suggestions re: things like redirecting the user to a "Verify your email" page after signing up and only showing the "Email verified" text if successful... let me know if I can clarify further or if you need any help!

@lpatmo
Copy link
Member

lpatmo commented Apr 13, 2021

@pdotsani Thanks for pushing up your commits! Finally got around to reviewing. :) I pushed up 60f4594 which makes sure there is a dependency array in the useEffect; otherwise it caused some errors in the build. Also pushed up a commit 56b2602 so that users who are redirected to the verify-email page see a notice to check their email instead of only the error.

Otherwise, looks great! I'll make a note in the backend ticket that we need to replace localhost:8000 with localhost:3000 and api-staging.codebuddies.org.

@lpatmo lpatmo force-pushed the feature/update-registration-flow branch from 56b2602 to a637bbf Compare April 13, 2021 07:09
variant="outlined"
shape="rounded"
size="large"
count={Math.floor(count / 10)}
Copy link

@notswedish notswedish Apr 13, 2021

Choose a reason for hiding this comment

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

small nitpick: I would move computations like these out of the rendering of components and before the return statement

Copy link
Member

Choose a reason for hiding this comment

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

Good suggestion -- thanks @turretd!

API_URL: 'http://localhost:8000',
};

export const config = process.env.NODE_ENV === 'development' ? dev : prod;

Choose a reason for hiding this comment

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

really love this approach 🙌

@pdotsani pdotsani force-pushed the feature/update-registration-flow branch from a637bbf to d29540f Compare April 15, 2021 00:05
@lpatmo lpatmo force-pushed the feature/update-registration-flow branch from d29540f to a637bbf Compare April 18, 2021 01:11
@lpatmo lpatmo merged commit 9112cc3 into main Apr 18, 2021
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.

4 participants