views.py 文件源码

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

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

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


问题


面经


文章

微信
公众号

扫码关注公众号