Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django没有升级密码_Django - Fatal编程技术网

Django没有升级密码

Django没有升级密码,django,Django,我正在为新用户使用Bcrypt_SHA256,但在旧系统中,我必须导入一些使用PBKDF_SHA256的用户帐户。根据密码,登录时应升级密码 我有一个自定义身份验证功能,当我在旧帐户上调用它时,密码不会得到升级 @classmethod def authenticate(cls, app, email, password): app_user = cls.find_by_email(app, email) # User not found if not app_user

我正在为新用户使用Bcrypt_SHA256,但在旧系统中,我必须导入一些使用PBKDF_SHA256的用户帐户。根据密码,登录时应升级密码

我有一个自定义身份验证功能,当我在旧帐户上调用它时,密码不会得到升级

@classmethod
def authenticate(cls, app, email, password):
    app_user = cls.find_by_email(app, email)

    # User not found
    if not app_user:
        return

    # User found but password incorrect
    if not hashers.check_password(password, app_user.password):
        app_user.failed_logins_count += 1
        app_user.save()
        return

    # Failed login count should be reset to 0 on successful login
    app_user.failed_logins_count = 0
    app_user.save()
    return app_user
以下是我的设置:

PASSWORD_HASHERS = (
    'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
    'django.contrib.auth.hashers.BCryptPasswordHasher',
    'django.contrib.auth.hashers.PBKDF2PasswordHasher',
    'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
    'django.contrib.auth.hashers.SHA1PasswordHasher',
    'django.contrib.auth.hashers.MD5PasswordHasher',
    'django.contrib.auth.hashers.CryptPasswordHasher',
)

正确返回用户,但密码不会更改。由于我的自定义功能,我是否需要手动升级密码,因为文档不可用;无法清除,或者是其他问题?

这是因为您在调用时没有
setter
参数


为什么不直接调用
用户
实例?它将为您插入
设置器

啊,文档在