title: How do I prevent calls to the Facebook API for non-first sessions?
body: <p>My app authenticates users through Facebook with OmniAuth and it works fine but every time a user has to create a session and sign in, the request to Facebook takes up to a minute because it is calling a lot of information through the API. How do I refactor the code below to only call the graph objects (profile, likes, friends) for when it does <code>|| User.create_with_omniauth(auth,omniauth)</code>?</p>
  
  <pre><code>def create  
    auth = request.env["omniauth.auth"]
    omniauth = request.env["omniauth.auth"]
    user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth,omniauth)     
  
    session[:user_id] = user.id  
    session['fb_auth'] = request.env['omniauth.auth']
    session['fb_access_token'] = omniauth['credentials']['token']
    session['fb_error'] = nil
  
    @graph = Koala::Facebook::GraphAPI.new(current_user.token)
    current_user.profile = @graph.get_object("me")
    current_user.likes = @graph.get_connections("me", "likes")
    current_user.friends = @graph.get_connections("me", "friends")
    current_user.save
    redirect_to root_url 
  end
  </code></pre>