Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/7533.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed `reset-admin-password` command failing when using `--random` option on Django 5.
6 changes: 5 additions & 1 deletion pulpcore/app/management/commands/reset-admin-password.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import string
import secrets

from getpass import getpass
from gettext import gettext as _

Expand Down Expand Up @@ -34,7 +37,8 @@ def add_arguments(self, parser):
def handle(self, *args, **options):
user = User.objects.get_or_create(username="admin", is_superuser=True, is_staff=True)[0]
if options["random"]:
password = User.objects.make_random_password(length=20)
alphabet = string.ascii_letters + string.digits
password = "".join(secrets.choice(alphabet) for i in range(20))
user.set_password(password)
user.save()
self.stdout.write(_('Successfully set "admin" user\'s password to "%s".') % password)
Expand Down
Loading