Ticket #15371: createsuperuser_no_pwd.patch

File createsuperuser_no_pwd.patch, 1.9 KB (added by yishaibeeri, 4 years ago)
  • django/contrib/auth/management/commands/createsuperuser.py

     
    5353            except exceptions.ValidationError:
    5454                raise CommandError("Invalid email address.")
    5555
    56         password = ''
     56        # If not provided, create the user with an unusable password
     57        password = None
    5758
    5859        # Try to determine the current system user's username to use as a default.
    5960        try:
  • django/contrib/auth/tests/basic.py

     
    6262        self.assertEqual(command_output, 'Superuser created successfully.')
    6363        u = User.objects.get(username="joe")
    6464        self.assertEquals(u.email, 'joe@somewhere.org')
    65         self.assertTrue(u.check_password(''))
     65       
     66        # created password should be unusable
     67        self.assertFalse(u.has_usable_password())
    6668
    6769        # We can supress output on the management command
    6870        new_io = StringIO()
     
    7779        self.assertEqual(command_output, '')
    7880        u = User.objects.get(username="joe2")
    7981        self.assertEquals(u.email, 'joe2@somewhere.org')
    80         self.assertTrue(u.check_password(''))
     82        self.assertFalse(u.has_usable_password())
    8183
     84
    8285        new_io = StringIO()
    8386        call_command("createsuperuser",
    8487            interactive=False,
     
    8891        )
    8992        u = User.objects.get(username="joe+admin@somewhere.org")
    9093        self.assertEquals(u.email, 'joe@somewhere.org')
    91         self.assertTrue(u.check_password(''))
     94        self.assertFalse(u.has_usable_password())
    9295
Back to Top