Opened 8 years ago

Closed 7 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)

comment:1 by Abhishek Bera, 8 years ago

Owner: changed from nobody to Abhishek Bera
Status: new → assigned

in reply to:  1 comment:2 by Abhishek Bera, 8 years ago

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

Last edited 8 years ago by Abhishek Bera (previous) (diff)

comment:3 by Claude Paroz, 8 years ago

Has patch: set
Triage Stage: Unreviewed → Accepted
Type: Bug → Cleanup/optimization

comment:4 by Tim Graham, 8 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 Abhishek Bera, 8 years ago

Owner: Abhishek Bera removed
Status: assigned → new

comment:6 by Daniel Rios, 7 years ago

Owner: set to Daniel Rios
Status: new → assigned

comment:7 by Carlton Gibson, 7 years ago

Patch needs improvement: unset

comment:8 by Carlton Gibson, 7 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 Daniel Rios, 7 years ago

Patch needs improvement: unset

comment:10 by Carlton Gibson, 7 years ago

Triage Stage: Accepted → Ready for checkin
Version: 2.1 → master

comment:11 by Carlton Gibson <carlton.gibson@…>, 7 years ago

Resolution: → fixed
Status: assigned → closed

In b5a5c92c:

Fixed #30066 -- Enabled super user creation without email and password

Note: See TracTickets for help on using tickets.
Back to Top