Skip to content

Commit ed5719d

Browse files
gerrod3mdellweg
authored andcommitted
Fix --random on reset-admin-password
fixes: #7533
1 parent e961dca commit ed5719d

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

CHANGES/7533.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed `reset-admin-password` command failing when using `--random` option on Django 5.

pulpcore/app/management/commands/reset-admin-password.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import string
2+
import secrets
3+
14
from getpass import getpass
25
from gettext import gettext as _
36

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

0 commit comments

Comments
 (0)