Note that there are some explanatory texts on larger screens.

plurals
  1. PORedirect loop with Rails & Omniauth on before_filter
    primarykey
    data
    text
    <p>I am currently developing a facebook app which will require the user to be signed in prior to being able to access the app.</p> <p>I have a <code>before_filter</code> on the <code>application_controller</code> to check if the user is logged in and if not redirect them to the proper sign in path.</p> <p>This is the code thus far:</p> <pre><code>Application Controller before_filter :check_sign_in def check_sign_in unless user_signed_in? redirect_to signin_path end private def current_user begin @current_user ||= User.find(session[:user_id]) if session[:user_id] rescue Mongoid::Errors::DocumentNotFound nil end end def user_signed_in? return true if current_user end </code></pre> <p>I have my <code>routes.rb</code> I have the following for <code>signin_path</code></p> <pre><code>match '/signin' =&gt; 'sessions#new', :as =&gt; :signin </code></pre> <p>My <code>sessions#new</code> action looks as follows</p> <pre><code>def new redirect_to '/auth/facebook' end </code></pre> <p>The problem at hand though is with this I am getting a redirect loop error on which is reading as follows</p> <blockquote> <p>This webpage has a redirect loop<br> The webpage at <a href="http://localhost:3000/signin" rel="nofollow">http://localhost:3000/signin</a> has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.</p> </blockquote> <p>This seems to be more than likely because the sign in process to facebook also has a callback which I suspect is whats causing the loop. Is there a better approach to ensure a user is logged or another method to go about achieving what I had in mind?</p> <p>I am currently using Rails 3.1.3,<br> Ruby 1.9.3,<br> omniauth-facebook 1.2.0,<br> omniauth 1.0.2</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload