Note that there are some explanatory texts on larger screens.

plurals
  1. PORails : Devise with config.session_store :disabled
    primarykey
    data
    text
    <p>I am building a RESTful API that is stateless with Rails 3 and the gem <code>devise</code>.</p> <p>Since I don't want to store any session, I have disabled them by defining in <code>config/initializers/session_store.rb</code> :</p> <pre><code>MyApp::Application.config.session_store :disabled </code></pre> <p>All my Warden Strategies (http basic auth, token auth) don't store any information (<code>stored?</code> returns false).</p> <p>I am using in my controllers the helper <code>authenticate_user!</code> as a before_filter. I obtain the following error during the authentication:</p> <pre><code>NoMethodError (undefined method `[]' for nil:NilClass) : warden (1.2.1) lib/warden/session_serializer.rb:32:in `fetch' warden (1.2.1) lib/warden/proxy.rb:212:in `user' warden (1.2.1) lib/warden/proxy.rb:318:in `_perform_authentication' warden (1.2.1) lib/warden/proxy.rb:127:in `authenticate!' devise (2.2.3) lib/devise/controllers/helpers.rb:48:in `authenticate_user!' </code></pre> <p>The code in session_serializer at line 32 is the following method:</p> <pre><code>def fetch(scope) key = session[key_for(scope)] # it crashes here return nil unless key method_name = "#{scope}_deserialize" user = respond_to?(method_name) ? send(method_name, key) : deserialize(key) delete(scope) unless user user end </code></pre> <p>It crashes because <code>session</code> (ie @env['rack.sessions']) equals nil (session_store is indeed disabled). This is a default call, the strategies have not been called yet.</p> <p>Since I don't want to monkey patch, I am looking for a good way to achieve this with session_store disabled.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    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.
    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