views.py 文件源码

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

项目:nearby-API 作者: NearbyApp 项目源码 文件源码
def mergeGoogle():
    """Merges an existing Google account to an existing Facebook account.
    """
    form = MergeGoogleForm()
    # 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 does exist.
            if GoogleModel.doesUserExist(form.googleId.data):
                googleUser = GoogleModel.getUser(form.googleId.data)
                if UserModel.mergeUsers(g.currentUser['_id'], googleUser['_id']):
                    return json.dumps({'result':'OK'}), 200
            else:
                return abort(404)
        else:
            return abort(401)

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


问题


面经


文章

微信
公众号

扫码关注公众号