Example #1
0
def oauthProcess(type, accountId, name, session):
    oauthHandle = Oauth(oauthId=accountId, name=name, type=type)
    user = oauthHandle.initAuth()
    if user['code'] == 200:
        session['user'] = user['userName']
        session.permanent = True
        return redirect('/')
    else:
        session['userId'] = user['userId']
        session['user'] = name
        return redirect('/auth/rename/%d' %user['userId'])
Example #2
0
def rename():
    if request.method == 'GET':
        userId = int(request.args.get('userId'))
        oauthHandle = Oauth(userId=userId)
        isUser = oauthHandle.isUser(session)
        return jsonify(isUser)
    else:
        userId = int(request.json['userId'])
        name = request.json['userName']
        oauthHandle = Oauth(userId=userId, name=name)
        isUser = oauthHandle.isUser(session)
        if isUser['code'] == 200:
            return jsonify(oauthHandle.rename(session))
        return jsonify(isUser)