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)

comment:1 by Abhishek Bera, 6 years ago

Owner: changed from nobody to Abhishek Bera
Status: newassigned

in reply to:  1 comment:2 by Abhishek Bera, 6 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 6 years ago by Abhishek Bera (previous) (diff)

comment:3 by Claude Paroz, 6 years ago

Has patch: set
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

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

Owner: Abhishek Bera removed
Status: assignednew

comment:6 by Daniel Rios, 5 years ago

Owner: set to Daniel Rios
Status: newassigned

comment:7 by Carlton Gibson, 5 years ago

Patch needs improvement: unset

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

Patch needs improvement: unset

comment:10 by Carlton Gibson, 5 years ago

Triage Stage: AcceptedReady for checkin
Version: 2.1master

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

Resolution: fixed
Status: assignedclosed

In b5a5c92c:

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

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