Skip to content

Commit

Permalink
Fixed #15371 -- Ensure that a superuser created with the createsuperu…
Browse files Browse the repository at this point in the history
…ser management command with --noinput has an invalid password, not a blank password. Thanks to yishaibeeri for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15631 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Feb 22, 2011
1 parent 37343ba commit b9a20d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion django/contrib/auth/management/commands/createsuperuser.py
Expand Up @@ -53,7 +53,8 @@ def handle(self, *args, **options):
except exceptions.ValidationError:
raise CommandError("Invalid email address.")

password = ''
# If not provided, create the user with an unusable password
password = None

# Try to determine the current system user's username to use as a default.
try:
Expand Down
9 changes: 6 additions & 3 deletions django/contrib/auth/tests/basic.py
Expand Up @@ -62,7 +62,9 @@ def test_createsuperuser_management_command(self):
self.assertEqual(command_output, 'Superuser created successfully.')
u = User.objects.get(username="joe")
self.assertEquals(u.email, 'joe@somewhere.org')
self.assertTrue(u.check_password(''))

# created password should be unusable
self.assertFalse(u.has_usable_password())

# We can supress output on the management command
new_io = StringIO()
Expand All @@ -77,7 +79,8 @@ def test_createsuperuser_management_command(self):
self.assertEqual(command_output, '')
u = User.objects.get(username="joe2")
self.assertEquals(u.email, 'joe2@somewhere.org')
self.assertTrue(u.check_password(''))
self.assertFalse(u.has_usable_password())


new_io = StringIO()
call_command("createsuperuser",
Expand All @@ -88,5 +91,5 @@ def test_createsuperuser_management_command(self):
)
u = User.objects.get(username="joe+admin@somewhere.org")
self.assertEquals(u.email, 'joe@somewhere.org')
self.assertTrue(u.check_password(''))
self.assertFalse(u.has_usable_password())

0 comments on commit b9a20d1

Please sign in to comment.