Ejemplo n.º 1
0
def register():
    print 'DAFUK....'
    @async
    @copy_current_request_context
    def fetch_and_populate_current_user_from_linkedin_async(db):
        fetch_and_populate_current_user_from_linkedin(db)

    # TODO better error handling.. what's the way to do it?
    if 'user_id' in session:
        print 'User already exists and logged in...'
        return redirect(url_for('index'))
    user = get_current_linkedin_user()
    if user and user.is_registered:
        print 'User already exists and is registered...'
        return redirect(url_for('index'))
    if not get_linkedin_oauth_token():
        print 'User not logged in...'
        return redirect(url_for('index'))
    if not user:
        print 'creating hollow user with linkedin_id = ' + str(get_linkedin_id())
        user = User(get_linkedin_id())
        db.session.add(user)
        db.session.commit()

    log_event(session.get('user_id'), 'register', {'ip': request.remote_addr})
    fetch_and_populate_current_user_from_linkedin_async(db)
    print 'F*****G DONE'
    return render_template('loading.html', current_user=user)
Ejemplo n.º 2
0
def index():
    if not get_linkedin_oauth_token():
        log_event(None, 'home', {'ip': request.remote_addr})
        return render_template('home.html')
    if 'user_id' not in session:
        return login_callback()
    return redirect(url_for('feed'))