Opened 11 months ago

Closed 3 months 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: master
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 Changed 11 months ago by Abhishek Bera

Owner: changed from nobody to Abhishek Bera
Status: newassigned

comment:2 in reply to:  1 Changed 11 months ago by Abhishek Bera

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 11 months ago by Abhishek Bera (previous) (diff)

comment:3 Changed 11 months ago by Claude Paroz

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

comment:4 Changed 11 months ago by Tim Graham

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 Changed 10 months ago by Abhishek Bera

Owner: Abhishek Bera deleted
Status: assignednew

comment:6 Changed 5 months ago by Daniel Rios

Owner: set to Daniel Rios
Status: newassigned

comment:7 Changed 5 months ago by Carlton Gibson

Patch needs improvement: unset

comment:8 Changed 5 months ago by Carlton Gibson

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 Changed 5 months ago by Daniel Rios

Patch needs improvement: unset

comment:10 Changed 3 months ago by Carlton Gibson

Triage Stage: AcceptedReady for checkin
Version: 2.1master

comment:11 Changed 3 months ago by Carlton Gibson <carlton.gibson@…>

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