-
Notifications
You must be signed in to change notification settings - Fork 6
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.email field is not mandatory and remain blank=True
#7
Comments
blank=True
blank=True
blank=True
blank=True
blank=True
Hey @trottomv. Yes. Of course. Since I think the additional constraint is required, and should be mentioned in the README briefly too. Good spot! 😜 |
Tests for the We can mung the validation exclusions at the form level, so that may need some thought. |
The question of the forms could open a nice chapter of reflection, which perhaps would be better managed separately (but I'm not quite sure).
could be sufficient to guarantee login with the email and could avoid and make unnecessary the whole customized part on |
I think that's going off the right path. The idea is simply to allow login by email with the default user model. Once we start messing too much we've lost the benefit of that. In general here, overriding Happy to input if you're unsure... — If you put together the test case we can see what's needed to make it pass 😜 |
Catching this issue is a nice to have: nobody who wants login by email is going to let users sign up without an email address 😜 But, yes, let's catch it. |
Hi @carltongibson In Django's Just below at line 814, the exclude is passed to You don't think so? 🤔 |
Not sure without a test case 😜 That's where I'd begin. Let's have a test that fails on Then if it passes when we add the constraint that'd be job done 😜 |
OK, great. Sounds like this is the right path. If you want to open a PR when you're happy I will take a look. Thanks @trottomv |
Hi @carltongibson,
I'm here again, because your solution seems really interesting to me. I noticed, though, that the
email
field remains withblank=True
parameter and since it's not a required field it's not subject to any validation.I've already drafted some code on my forked repo. There might still be somethings to fix, such as the split of the migrations, but I would like to have your feedback on it before opening a pull request on this repo.
If you want, you can take a look at this link in the meantime.
https://github.com/trottomv/django-unique-user-email/pull/1/files
The problem: without a constraint on empty email, adding two user with an empty email to database is raised an IntegrityError from the existent
UniqueConstraint
, so the field should have another constraint to check the email value is not empty.first solution on my mind: ok, easy... add some
blank=False
handler onUser.email
fromunique_user_email.apps
configuratorbut, no, is not so easy because the MigrationAutoDetector remove it (and something similar to the problem reported on issue #5 happens)
workaround solution: Add also a
CheckConstraint
as you can see into draft code linked beforeThe text was updated successfully, but these errors were encountered: