Rails 3 - Devise With OmniAuth - Redirect after signing in goes to /users/sign_in

后端 未结 3 771
滥情空心
滥情空心 2020-12-25 08:17

Im using devise with omniauth for signing in users with facebook. I want them to be redirected after signing in to the page they were on after before signing in.

I\'

相关标签:
3条回答
  • 2020-12-25 08:27

    You can pass a parameter like: /auth/facebook?referrer=/path/to/redirect

    After the Facebook authentication this parameter will be available to you in env["omniauth.params"].

    0 讨论(0)
  • 2020-12-25 08:33

    I answered this here

    Devise doesn't redirect properly to stored location when using omniauth provider like facebook

    in application_controller.rb

     def after_sign_in_path_for(resource_or_scope)
       if request.env['omniauth.origin']
          request.env['omniauth.origin']
        end
    end
    
    0 讨论(0)
  • 2020-12-25 08:46

    did you consider the Devise provided helper sign_in_and_redirect(resource_or_scope, *args) (details can be found here)? You also get sign_out_and_redirect(resource_or_scope) amongst others.

    Q2. do try inspecting session[:return_to] - it's most likely nil.

    0 讨论(0)
提交回复
热议问题