Commit 95800be0 by Edward Zarecor Committed by GitHub

Merge pull request #12999 from edx/e0d/random-passwords

use random rather than unusable so they can be reset
parents 9d747fa6 8a18b2c3
...@@ -4,7 +4,7 @@ Django users, set/unset permission bits, and associate groups by name. ...@@ -4,7 +4,7 @@ Django users, set/unset permission bits, and associate groups by name.
""" """
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group from django.contrib.auth.models import Group, BaseUserManager
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.db import transaction from django.db import transaction
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
...@@ -81,7 +81,10 @@ class Command(BaseCommand): ...@@ -81,7 +81,10 @@ class Command(BaseCommand):
) )
if created: if created:
user.set_unusable_password() # Set the password to a random, unknown, but usable password
# allowing self-service password resetting. Cases where unusable
# passwords are required, should be explicit, and will be handled below.
user.set_password(BaseUserManager().make_random_password(25))
self.stderr.write(_('Created new user: "{}"').format(user)) self.stderr.write(_('Created new user: "{}"').format(user))
else: else:
# NOTE, we will not update the email address of an existing user. # NOTE, we will not update the email address of an existing user.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment