예제 #1
0
파일: account.py 프로젝트: Gwill/zerqu
def social_authorize(name):
    social = SocialUser.handle_authorized_response(name)
    if social is None:
        return 'error'

    if current_user and not social.user_id:
        social.user_id = current_user.id
        with db.auto_commit():
            db.session.add(social)

    if social.user_id:
        user = User.cache.get(social.user_id)
        UserSession.login(user, True)
        next_url = session.pop('next_url', '/')
        return redirect(next_url)

    session['social.service'] = social.service
    session['social.uuid'] = social.uuid

    if name == 'google' and social.info.get('verified_email'):
        email = social.info.get('email')
        if email:
            token = create_email_signature(email, 'signup')
            url = url_for('.signup', token=token)
            return redirect(url)

    return 'TODO'
예제 #2
0
def social_authorize(name):
    social = SocialUser.handle_authorized_response(name)
    if social is None:
        return 'error'

    if current_user and not social.user_id:
        social.user_id = current_user.id
        with db.auto_commit():
            db.session.add(social)

    if social.user_id:
        user = User.cache.get(social.user_id)
        UserSession.login(user, True)
        next_url = session.pop('next_url', '/')
        return redirect(next_url)

    session['social.service'] = social.service
    session['social.uuid'] = social.uuid

    if name == 'google' and social.info.get('verified_email'):
        email = social.info.get('email')
        if email:
            token = create_email_signature(email, 'signup')
            url = url_for('.signup', token=token)
            return redirect(url)

    return 'TODO'
예제 #3
0
파일: account.py 프로젝트: Gwill/zerqu
def social_login(name):
    remote = SocialUser.get_remote_app(name)
    if not remote:
        abort(404)

    session['next_url'] = request.referrer or '/'
    callback = full_url('.social_authorize', name=name)
    return remote.authorize(callback=callback)
예제 #4
0
def social_login(name):
    remote = SocialUser.get_remote_app(name)
    if not remote:
        abort(404)

    session['next_url'] = request.referrer or '/'
    callback = full_url('.social_authorize', name=name)
    return remote.authorize(callback=callback)