密码格式无效或未知的哈希算法

2023-12-23

我网站上的一位用户最近在尝试登录时成功触发了此回溯。在 Django Admin 中,他的密码为Invalid password format or unknown hashing algorithm.

我不知道是什么原因造成的。到目前为止,这只是一个孤立的案例,我和其他用户已成功注册并登录该网站。

追溯

Traceback (most recent call last):

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/var/git/bbox/userprofile/views.py", line 67, in login_view
   if form.is_valid():

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/forms/forms.py", line 124, in is_valid
   return self.is_bound and not bool(self.errors)

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/forms/forms.py", line 115, in _get_errors
   self.full_clean()

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/forms/forms.py", line 271, in full_clean
   self._clean_form()

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/forms/forms.py", line 299, in _clean_form
   self.cleaned_data = self.clean()

 File "/var/git/bbox/userprofile/forms.py", line 83, in clean
   self.user_cache = authenticate(username=username, password=password)

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 45, in authenticate
   user = backend.authenticate(**credentials)

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/contrib/auth/backends.py", line 15, in authenticate
   if user.check_password(password):

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/contrib/auth/models.py", line 304, in check_password
   return check_password(raw_password, self.password, setter)

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/contrib/auth/hashers.py", line 42, in check_password
   hasher = get_hasher(algorithm)

 File "/home/gituser/.virtualenvs/bbox/lib/python2.7/site-packages/django/contrib/auth/hashers.py", line 115, in get_hasher
   "setting?" % algorithm)

ValueError: Unknown password hashing algorithm ''. Did you specify it in the PASSWORD_HASHERS setting?

不要将密码设置为空字符串,而是使用以下命令将密码设置为不可用set_unusable_password()的方法User model https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.set_unusable_password:

user.set_unusable_password()

请参阅文档中的更多内容:https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.set_unusable_password https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.set_unusable_password

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

密码格式无效或未知的哈希算法 的相关文章

随机推荐