Omniauth.origin is nil

426 views
Skip to first unread message

Laurent Kretz

unread,
Apr 26, 2011, 11:07:23 AM4/26/11
to omni...@googlegroups.com

Hi guys, 

I'm having trouble with omniauth.origin, which doesn't seem to be set. Is there anything special to do to make it work ?

I posted on StackO (http://stackoverflow.com/questions/5792350/omniauth-origin-is-nil), but copied it below. Thank you for your help !

Laurent

*****************************

Hi all,

I'm using the gem with twitter. On callback, check if the user exists and create him or send him back to the homepage. 
I might be doing something wrong, but in my callback code, request.env['omniauth.origin'] is nil.

My code is quite 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 raise request.env['omniauth.origin'] right after callback, i get a nil object.

Thanks for your help!


Reply all
Reply to author
Forward
0 new messages