RailsApps/rails-composer · error

You need to sign in for access to this page.

Error message

You need to sign in for access to this page.

What it means

Error "You need to sign in for access to this page." thrown in RailsApps/rails-composer.

Source

Thrown at files/app/controllers/application_controller-omniauth.rb:29

      rescue Exception => e
        nil
      end
    end

    def user_signed_in?
      return true if current_user
    end

    def correct_user?
      @user = User.find(params[:id])
      unless current_user == @user
        redirect_to root_url, :alert => "Access denied."
      end
    end

    def authenticate_user!
      if !current_user
        redirect_to root_url, :alert => 'You need to sign in for access to this page.'
      end
    end

end

View on GitHub (pinned to 5a9985f6dd)

Solutions

  1. Sign in through the OmniAuth provider route (for example /auth/provider) so a session is created.
  2. Make sure the OmniAuth callback stores session[:user_id] = user.id on successful authentication.
  3. Check session cookie settings and protect_from_forgery so the session is not discarded between requests.

Example fix

def create
  user = User.find_or_create_from_auth_hash(auth_hash)
  session[:user_id] = user.id
  redirect_to root_url
end

When it happens

Trigger: Shown as a redirect alert by authenticate_user! when current_user is nil, i.e. the visitor has no session[:user_id] or the session has expired or been reset.

Common situations: An anonymous visitor requests a page guarded by before_filter :authenticate_user!; the session cookie expired or was cleared; login succeeded but the callback never stored session[:user_id].


AI-assisted analysis of RailsApps/rails-composer@5a9985f6dd (2026-08-23). Data as JSON: /api/errors/1f99a827395b2c79. Report an issue: GitHub.