Opened 6 years ago
Closed 5 years ago
#30066 closed Cleanup/optimization (fixed)
UserManager.create_superuser doesn't allow for omitting email or password, unlike create_user which does.
Reported by: | Joshua Cannon | Owned by: | Daniel Rios |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Normal | Keywords: | create_superuser |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
I couldn't find any historical information on whether or not this is intentional, but create_user
/create_superuser
seem to mirror each other except that create_superuser
doesn't allow the caller to omit email
and password
parameters.
This commit introduced omitting password
, and this commit introduced omitting email
, but neither touches create_superuser
.
Change History (11)
follow-up: 2 comment:1 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 6 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
comment:4 by , 6 years ago
Patch needs improvement: | set |
---|
The documentation says, The prototype of create_superuser()
should accept the username field, plus all required fields as arguments." and "Unlike create_user()
, create_superuser()
must require the caller to provide a password."
For the default user mode, User.REQUIRED_FIELDS = ['email']
so that explains the original implementation. The documentation for CustomUserManager.create_user()
wasn't updated after f54135fa4dc9fd45d86ea2944191d58e00725779. It still says, "The prototype of create_user()
should accept the username field, plus all required fields as arguments." which is violated for the default case.
I don't have a strong opinion about how to proceed but if we proceed with the changes, some documentation changes are required.
comment:5 by , 6 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:6 by , 5 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:7 by , 5 years ago
Patch needs improvement: | unset |
---|
comment:8 by , 5 years ago
Patch needs improvement: | set |
---|
Just a couple of minor comments on the PR. Marking "Patch needs improvement", please uncheck that when those are addressed.
comment:9 by , 5 years ago
Patch needs improvement: | unset |
---|
comment:10 by , 5 years ago
Triage Stage: | Accepted → Ready for checkin |
---|---|
Version: | 2.1 → master |
I added a test case with no email and password for the super user which failed. later i changed the code in the models to email = None and password = None in the contrib/auth/models createsuperuser params and now the test case is passing