views.py 文件源码

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

项目:nearby-API 作者: NearbyApp 项目源码 文件源码
def linkGoogle():
    """Links a Google account to an existing Facebook account.
    """
    form = LinkGoogleForm()
    # Check if the Service-Provider is Facebook
    if form.validate_on_submit() and g.loginWith == 'Facebook' and g.currentUser['googleId'] is None:
        googleToken = GoogleModel.getTokenValidation(app.config['GOOGLE_CLIENT_ID'], form.token.data)
        if googleToken and googleToken['sub'] == form.googleId.data:
            # Continue only if the account doesn't exist yet.
            if not GoogleModel.doesUserExist(form.googleId.data):
                if GoogleModel.linkToUserId(g.currentUser['_id'], form.googleId.data):
                    return json.dumps({'result':'OK'}), 200
            else:
                return abort(403)
        else:
            return abort(401)

    return abort(400)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号