ruby on rails - Devise doesn't redirect properly to stored location when using omniauth provider like facebook -
I have some actions in my app that are protected and require user authentication Since I am planning, I certify I use the user! Before the filter to protect them, whenever the user hits the protected page, ask the user to log in and then redirect back to the protected page. This part works perfectly.
The problem is that when a user tries to login with Facebook through my app, the user does not redirect the login to the protected page after login. It always puts the user back in the root URL. This is not a problem with standard authentication
I suspect that there is something to do with the Pathstra method which requires ubiquitous integration. Any help would be greatly appreciated
Omniauth is my code snippet for callback:
def facebook # Applying the method below to your model omniauth = request.env Need to "[Omniauth.auth"] @user = User.find_for_facebook_oauth (omniauth, current_user) if @ user.persisted? Flash [: Notice] = I18n.t "devise.omniauth_callbacks.success" ,: type = & gt; "Facebook" sign_in_and_redirect @user ,: event = & gt; : Authentication other session ["devise.facebook_data"] = env ["omniauth.auth"] redirect_to new_user_registration_url End end DEF passthru render: file = & gt; "# {Rails.root} / Public / 404.html" ,: Status = & gt; 404 ,: layout = & gt; False end We use Facebook JS to get the access code which will again prompt Omniauth_callback_controller.rb and the user is.
I found out that the original URL has been saved in the request. application_controller.rb
df after_sign_in_path_for (resource_or_scope) if requested.env ['omniauth.origin'] request in a treated request for us Click on .env ['omniauth .origin'] and end
Comments
Post a Comment