title: Devise Completed 401 Unauthorized in 1ms after apply strong parameter
body: <p>I just configured strong parameter in my app, all seems to be fine. But my devise login failed. I can still register a user and that will login the user in. I am on devise 3.1.1</p>
  
  <p>I added to application_controller:</p>
  
  <pre><code>   before_filter :configure_permitted_parameters, if: :devise_controller? 
  
       protected
        def configure_permitted_parameters
          devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password, :remember_me) }
          devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password) }
        end
  </code></pre>
  
  <p>In my model</p>
  
  <pre><code>   devise :database_authenticatable, :registerable,
       :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :invitable, :invite_for =&gt; 2.weeks, :authentication_keys =&gt; [:username]
  </code></pre>
  
  <p>And my log, there is a DEPRECATION WARNING: devise :token_authenticatable is deprecated., not sure if this is the problem?</p>
  
  <pre><code>       Started POST "/users/login" for 127.0.0.1 at 2013-10-09 21:54:13 +1300
        DEPRECATION WARNING: devise :token_authenticatable is deprecated. Please check Devise 3.1 release notes for more information on how to upgrade. (called from &lt;class:User&gt; at /home/jcui/Desktop/workspace/iv/app/models/user.rb:6)
          Configuration Load (0.4ms)  SELECT "configurations".* FROM "configurations" 
        Processing by Devise::SessionsController#create as HTML
          Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"G1aVfzHcwHAI7ao6sBLF9WtgJAWlQ8c5KlKzEHpZzTo=", "user"=&gt;{"email"=&gt;"xxx@gmail.com", "password"=&gt;"[FILTERED]", "remember_me"=&gt;"0"}, "commit"=&gt;"Sign in"}
        Completed 401 Unauthorized in 1ms
        Processing by Devise::SessionsController#new as HTML
          Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"G1aVfzHcwHAI7ao6sBLF9WtgJAWlQ8c5KlKzEHpZzTo=", "user"=&gt;{"email"=&gt;"xxx@gmail.com", "password"=&gt;"[FILTERED]", "remember_me"=&gt;"0"}, "commit"=&gt;"Sign in"}
          Rendered devise/shared/_links.erb (0.6ms)
          Rendered devise/sessions/new.html.erb within layouts/application (6.8ms)
        Completed 200 OK in 169ms (Views: 83.0ms | ActiveRecord: 0.0ms | Solr: 0.0ms)
  </code></pre>
  
  <p>I tried to output the resource error object in the session new view, but there is not error!!</p>
  
  <pre><code>#&lt;ActiveModel::Errors:0xe911424 @base=#&lt;User id: nil, email: "myemail@gmail.com", encrypted_password: "$2a$10$j6lAQhBNgsO01HuBjxbgCOdvd0biRehWhQct50ee8cAo...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil,
    sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: nil, updated_at: nil, api_key: nil, avatar: nil, deleted_at: nil, roles_mask: nil, subdomain_id: nil, 
    invitation_token: nil, invitation_sent_at: nil, invitation_accepted_at: nil, invitation_limit: nil, invited_by_id: nil, invited_by_type: nil, username: nil, avatar_processing: nil, lang: nil&gt;, @messages={}&gt;
  </code></pre>