Python django.contrib.auth.hashers 模块,is_password_usable() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.contrib.auth.hashers.is_password_usable()

项目:nhsuk-content-store    作者:nhsuk    | 项目源码 | 文件源码
def create_frontend_user_and_application(apps, schema_editor):
    # create user
    User = apps.get_model('auth', 'User')
    user = User.objects.create(
        username=USER_USERNAME,
        password=make_password(None)
    )
    assert not is_password_usable(user.password)  # double-check that the password is unusable

    # create application
    Application = apps.get_model("oauth2_provider", "Application")
    application = Application.objects.create(
        name=APPLICATION_NAME,
        user=user,
        client_type='confidential',
        authorization_grant_type='client-credentials'
    )

    # create access token
    AccessToken = apps.get_model("oauth2_provider", "AccessToken")
    AccessToken.objects.create(
        token=common.generate_token(),
        application=application,
        expires=timezone.now() + timedelta(days=(365 * 5)),
        scope='read'
    )