python类is_password_usable()的实例源码

0001_initial.py 文件源码 项目:nhsuk-content-store 作者: nhsuk 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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'
    )


问题


面经


文章

微信
公众号

扫码关注公众号