session - Rails + HTTPS: Filter chain halted as :ensure_proper_protocol rendered or redirected -
i think sessions , such screwing because of code added in ensure proper protocol (https on pages, , http on others). i'm not sure though. keep seeing filter chain halted :ensure_proper_protocol rendered or redirected in log.
the `:ensure_proper_protocol method referring method have in application controller:
class applicationcontroller < actioncontroller::base controllers_that_require_ssl = ['check_out', 'users', 'sessions', 'registrations', 'addresses', 'catalog_requests', 'wine_club/orders'] def ensure_proper_protocol unless rails.env.development? || rails.env.test? if request.format == "text/html" && request.protocol["https"] && !controllers_that_require_ssl.include?(params[:controller]) redirect_to "http://" + request.host + request.path end end end and controllers in controllers_that_require_ssl, add force_ssl so:
class checkoutcontroller < applicationcontroller force_ssl ... however, i'm wondering if switch in protocols screwing sessions up. session issues , error related? how fix "filter chain halted" error?
the session issues i'm having devise , authentication. have before filter :authenticate_user! , although manage log in, doesn't seem stay logged in. problem there no error messages. logs out reason, , i'm pretty sure it's because of redirect because have before filter in application controller see if user signed in, , uses devise helper method user_signed_in? see if user signed in. take @ log:
cache read: https://mysite-rc-preview.mysite.com/users/sign_in? started post "/users/sign_in" 69.193.194.58 @ 2013-09-04 12:09:38 -0400 processing sessionscontroller#create html parameters: {"utf8"=>"✓", "authenticity_token"=>"bsyhk5t7vpbutgkquvyix8cb7et7yojpe5m0v/g+do8=", "user"=>{"email"=>"emai@mysite.com", "password"=>"[filtered]"}, "commit"=>"log in"} inside setup_cart. current_cart_id 55005260 55005260 request.session_options[:id] = eecb979b4d7db5bfd28a3684ef7288d3 user load (2.9ms) select "users".* "users" "users"."email" = 'emai@mysite.com' limit 1 (1.9ms) begin (2.2ms) update "users" set "last_sign_in_at" = '2013-09-04 16:07:44.987529', "current_sign_in_at" = '2013-09-04 16:09:39.171144', "sign_in_count" = 34, "updated_at" = '2013-09-04 16:09:39.174358' "users"."id" = 350492 (10.6ms) commit begining get_or_create_cart session[:current_cart_id] 55005260 cart load (2.3ms) select "carts".* "carts" "carts"."user_id" = 350492 , "carts"."id" = 55005260 limit 1 cart load (2.2ms) select "carts".* "carts" "carts"."user_id" = 350492 end of get_or_create_cart session[:current_cart_id] 54993421 seocontent load (2.2ms) select "seo_contents".* "seo_contents" "seo_contents"."for_section" = 'default' limit 1 there's no session[:cvv] variable cart load (2.2ms) select "carts".* "carts" "carts"."web_cart_session" = 'eecb979b4d7db5bfd28a3684ef7288d3' cart load (2.4ms) select "carts".* "carts" "carts"."user_id" = 350492 , "carts"."name" = 'my cart' limit 1 cartitem load (2.2ms) select "cart_items".* "cart_items" "cart_items"."cart_id" = 55005260 order created_at (1.9ms) begin sql (2.4ms) delete "carts" "carts"."id" = $1 [["id", 55005260]] (6.5ms) commit redirected https://mysite-rc-preview.mysite.com/ completed 302 found in 408ms (activerecord: 42.0ms) cache read: https://mysite-rc-preview.mysite.com/? started "/" 69.193.194.58 @ 2013-09-04 12:09:39 -0400 processing sitecontroller#index html redirected http://mysite-rc-preview.mysite.com/ filter chain halted :ensure_proper_protocol rendered or redirected completed 302 found in 1ms (activerecord: 0.0ms) cache read: http://mysite-rc-preview.mysite.com/? started "/" 69.193.194.58 @ 2013-09-04 12:09:39 -0400 processing sitecontroller#index html inside setup_cart. current_cart_id 54993421 54993421 request.session_options[:id] = 4bec2bbc42e8213be89aaf6431b41535 inside not user_signed_in? clause of setup_cart it redirects me homepage after log in, okay, after redirects http:// ... / https:// ... / , causes user not signed in anymore. because sessions aren't being stored in database configured them be? have line in config/initializers/session_store.rb:
mysite::application.config.session_store :active_record_store
Comments
Post a Comment