Opened 7 months ago

Last modified 4 weeks ago

#30066 assigned Cleanup/optimization

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: 2.1
Severity: Normal Keywords: create_superuser
Cc: Triage Stage: Accepted
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 (9)

comment:1 Changed 7 months ago by Abhishek Bera

Owner: changed from nobody to Abhishek Bera
Status: newassigned

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

comment:3 Changed 7 months ago by Claude Paroz

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

comment:4 Changed 7 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 6 months ago by Abhishek Bera

Owner: Abhishek Bera deleted
Status: assignednew

comment:6 Changed 7 weeks ago by Daniel Rios

Owner: set to Daniel Rios
Status: newassigned

comment:7 Changed 6 weeks ago by Carlton Gibson

Patch needs improvement: unset

comment:8 Changed 5 weeks 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 4 weeks ago by Daniel Rios

Patch needs improvement: unset
Note: See TracTickets for help on using tickets.
Back to Top