paas_backends.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:TigerHost 作者: naphatkrit 项目源码 文件源码
def get_backend_authenticated_client(username, backend):
    """Creates a new authenticated client for the user
    and backend

    @type username: str
    @type backend: str

    @rtype: api_server.clients.base_client.BaseAuthenticatedClient

    @raises e: ClientError
    @raises e: BackendsError
    """
    try:
        user = User.objects.get(username__iexact=username)
    except User.DoesNotExist:
        raise BackendsUserError('{} does not exist.'.format(username))
    client = get_backend_client(backend)
    try:
        password = user.profile.get_credential(backend).get_password()
    except Profile.NoCredentials:
        raise BackendsUserError('{user} does not have access to {backend}.'.format(
            user=username, backend=backend))
    c, _ = client.login_or_register(
        user.username, password, user.email)
    return c
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号