fizista / django-password-validators

Additional libraries for validating passwords in Django.
BSD 3-Clause "New" or "Revised" License
51 stars 30 forks source link

TypeError: int() argument must be a string, a bytes-like object or a number, not 'ModelBase' #5

Closed aerasoft closed 4 years ago

aerasoft commented 4 years ago

Error is here https://github.com/fizista/django-password-validators/blob/master/django_password_validators/password_history/password_validation.py#L24

Traceback (most recent call last):
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 1772, in get_prep_value
    return int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'ModelBase'
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/allauth/account/views.py", line 215, in dispatch
    return super(SignupView, self).dispatch(request, *args, **kwargs)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/allauth/account/views.py", line 81, in dispatch
    **kwargs)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/allauth/account/views.py", line 193, in dispatch
    **kwargs)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/allauth/account/views.py", line 103, in post
    if form.is_valid():
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/forms/forms.py", line 180, in is_valid
    return self.is_bound and not self.errors
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/forms/forms.py", line 175, in errors
    self.full_clean()
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/forms/forms.py", line 377, in full_clean
    self._clean_form()
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/forms/forms.py", line 404, in _clean_form
    cleaned_data = self.clean()
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/allauth/account/forms.py", line 387, in clean
    user=dummy_user)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/allauth/account/adapter.py", line 296, in clean_password
    validate_password(password, user)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghingerENVR/lib/python3.7/site-packages/django/contrib/auth/password_validation.py", line 47, in validate_password
    validator.validate(password, user)
  File "/Users/flexpeace/Desktop/DjangoProjects/AWS-Ghinger/ghinger/django_password_validators/password_history/password_validation.py", line 24, in validate
    for user_config in UserPasswordHistoryConfig.objects.filter(user=user):
fizista commented 4 years ago

It seems to me that there is a bad use of the password checking API in allauth. I've made some changes that silence the problem, but leave information about it in logs.