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

[User Registration] Make email required on backend #111

Closed
lpatmo opened this issue Mar 22, 2020 · 18 comments
Closed

[User Registration] Make email required on backend #111

lpatmo opened this issue Mar 22, 2020 · 18 comments
Assignees
Labels
enhancement New feature or request P1 for MVP

Comments

@lpatmo
Copy link
Member

lpatmo commented Mar 22, 2020

Context

We need to make sure the email field is required when a new user is registered via the /auth/users API endpoint.

Acceptance Criteria

[ ] Change the line in the model to make sure email is required
[ ] Make migrations file and run migrations
[ ] Add models test
[ ] Make sure tests pass

Ticket sizing

1 (small)

@lpatmo lpatmo added the good first issue Good for newcomers label Mar 22, 2020
@lpatmo lpatmo added this to the User Registration milestone Mar 22, 2020
@BethanyG
Copy link
Member

BethanyG commented Mar 22, 2020

@lpatmo This is not an API change and since we are using a custom model, it is an addition (I keep forgetting that too!)

Add email in users_user as a required (non-blank) field.

Since we are using a custom user model, this change will need to be made in the model.py file of the users app.

@BethanyG BethanyG added the enhancement New feature or request label Mar 22, 2020
@lpatmo lpatmo self-assigned this Mar 22, 2020
@lpatmo
Copy link
Member Author

lpatmo commented Mar 22, 2020

Gah I was going to give this to @bkbuilt or someone else who expressed interest since it's a good beginner issue, but started playing around to test it out in a new branch and realized I might as well create a PR for it.

PR: https://github.com/chris48s/backend/pull/1/files

Note that it is based off of #109.

I documented my implementation steps in chris48s#1, so if something drastic changes in #109 the implementation steps should be easily re-created.

@lpatmo
Copy link
Member Author

lpatmo commented Mar 22, 2020

(Or... if #109 gets merged in first, I'll just re-submit the PR to point towards master instead of towards Chris' branch)

@BethanyG
Copy link
Member

@lpatmo I hate to do this to you, but for clarities sake, I really think this should be a separate PR...just so we keep related PRs with their milestones??

@lpatmo
Copy link
Member Author

lpatmo commented Mar 22, 2020

No problem, I meant to do this as a separate PR, but realized this was dependent on the other PR being merged in 😅. Happy to resubmit the PR to master after that other PR is resolved!

@BethanyG
Copy link
Member

🤔 ...yeah. We need to get our arses in gear around testing....aaaaand you'll need to add a model test for your change 😄 .

@lpatmo
Copy link
Member Author

lpatmo commented Mar 22, 2020

Haha, cool! I missed that in my acceptance criteria 😅

@lpatmo
Copy link
Member Author

lpatmo commented Sep 4, 2020

I think we can recreate what I did in https://github.com/chris48s/backend/pull/1/files, plus add some tests to the model. Need to research where that will live, though 🤔

@bengineerdavis
Copy link

I think we can recreate what I did in https://github.com/chris48s/backend/pull/1/files, plus add some tests to the model. Need to research where that will live, though thinking

Do you mind adding this and other things you find for our 'prep' in our public docs?

@BethanyG
Copy link
Member

BethanyG commented Sep 4, 2020

@lpatmo @bengineerdavis @tgrrr -- apologies for not replying to this earlier. This change is required for #113, #110, #113 which I am currently working on. I don't think that what I am doing will interfere with this -- or vice-versa, but there may be merge conflicts if we're both checking in code in the next few days.

@lpatmo
Copy link
Member Author

lpatmo commented Sep 4, 2020

Thanks for the heads up! We probably won't have a PR up sooner than next Tuesday (when https://codebuddies.org/hangout/nAadjwkpEsF9gsTGM is scheduled), fwiw.

In the meantime, added this as reading to the google doc: https://www.obeythetestinggoat.com/book/chapter_database_layer_validation.html

@BethanyG
Copy link
Member

BethanyG commented Sep 7, 2020

In investigating further the changes needed for email validation in registration, I've made a few discoveries that now (I believe) cancel out this change entirely.

Firstly, I didn't realize that cookiecutter-django (which we used to generate this project) pre-installed django-allauth in addition to implementing a custom user model. See Cookiecutter Settings Page for a little info on that.

Secondly, in looking at the DB and the allauth configuration docs and the allauth custom user models docs around configuration and custom user models, I noticed the following:

image

and

image

...which means that allauth - either configured for social OR configured for email uses a special app and set of tables under accounts to store emails for users for authentication -- not the users_user table. The flag ACCOUNT_EMAIL_REQUIRED=True is for the account app and the account_email table -- NOT the email field in the users app, or the users_user table!

Why is this important? Having django-allauth pre-installed means we don't have to create the user registration/validation/confirmation flow from scratch - much of it is handled by the allauth app. BUT. That also means that the email requirement needs to be applied through django-allauth -- not through the users model.

Apologies that I didn't see this before -- would probably have saved a lot of reading and work. We may still need to add an email field to the model...I am not quite clear on the interactions just yet.

@BethanyG
Copy link
Member

BethanyG commented Sep 7, 2020

Recommend that if you do go ahead and make this change that it not be merged (nor should the registrations changes I am making be merged) until we decide which direction we are going to go with registration.

@lpatmo
Copy link
Member Author

lpatmo commented Sep 7, 2020

D'oh and LOL SO GLAD YOU NOTICED THIS!!

I'll continue the discussion re: authentication in #178 :)

(In the meantime, I'll close this issue since it's not needed anymore)

@lpatmo lpatmo closed this as completed Sep 7, 2020
@tgrrr
Copy link
Contributor

tgrrr commented Sep 8, 2020

Copied for reference here:

@BethanyG wrote on #173:

We closed #111, because the authentication scheme we are using doesn't trigger off an email on the custom user model. See comments there and on discussion number
#178.

@tgrrr
Copy link
Contributor

tgrrr commented Sep 8, 2020

I also found this branch from @lpatmo working on this issue, dropping the link here for reference: ff5c10b

@BethanyG
Copy link
Member

BethanyG commented Sep 8, 2020

@tgrrr - this issue has been closed by @lpatmo and is unlikely to be reopened. Please see the comments above. Unless we decide we are re-creating email validation and user registration flows from scratch (very unlikely), we will have no need for the change. @lpatmo work was never merged and is not present in main.

@bengineerdavis
Copy link

bengineerdavis commented Sep 8, 2020 via email

@codebuddies codebuddies locked and limited conversation to collaborators Sep 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request P1 for MVP
Projects
None yet
Development

No branches or pull requests

4 participants