Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #26951 -- Fixed AuthenticationForm to work with integer usernames. #6977

Closed
wants to merge 1 commit into from

Conversation

alexyer
Copy link
Contributor

@alexyer alexyer commented Jul 26, 2016

@charettes charettes changed the title Fixed #26951 -- Fixed AuthenticationForm bug Fixed #26951 -- Fixed AuthenticationForm to work with integer usernames. Jul 26, 2016
@override_settings(AUTH_USER_MODEL='auth_tests.CustomUserWithIntegerUsername')
def test_integer_field(self):
class CustomAuthenticationForm(AuthenticationForm):
class Meta(UserCreationForm.Meta):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserCreationForm.Meta looks like a typo to me. Perhaps you meant AuthenticationForm.Meta?

@alexyer
Copy link
Contributor Author

alexyer commented Jul 29, 2016

Updated tests. Thanks, @berkerpeksag!

USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['username', 'password']

def __str__(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think __str__ can be omitted here. If it needs to stay, CustomUserWithIntegerUsername should be wrapped by @python_2_unicode_compatible.

Fixed AuthenticationForm bug when USERNAME_FIELD is an IntegerField.
Added explicit check for None for `username` and `password` in
`django.contrib.auth.forms.AuthenticationForm.clean` method.
@alexyer
Copy link
Contributor Author

alexyer commented Aug 8, 2016

Updated code style. Thanks, @berkerpeksag!

@timgraham
Copy link
Member

The test isn't working as a regression test because it passes before the fix is applied. I added one line to fix it: self.assertEqual(form.user_cache, user).

Merged in 975a76a, thanks!

@timgraham timgraham closed this Aug 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants