I use the gem with twitter. When calling back, check if the user exists and create it, or send it to the home page.
I might be doing something wrong, but in my callback code, request.env ['omniauth.origin'] is nil .
My code is pretty simple:
whatever.html.erb
<%= link_to image_tag("twitter-connect.png"), "/auth/twitter" %>
routes.rb
match "/auth/:provider/callback" => "sessions#create"
sessions_controller.rb
def create auth = request.env["omniauth.auth"] user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth) if !user.email redirect_to confirm_path, :notice => "Add your email!" else redirect_to request.env['omniauth.origin'] || root_url, :notice => "Signed in!" end end
If I return request.env ['omniauth.origin'] immediately after the callback, I get a nil object.
Thanks for your help!
source share