plataformatec/devise — Issue #1533: [master] issues with username warden strategy
Author: masterkain
Created: 2011-12-29 17:19:56+00:00
State: open

I'm following this wiki article: https://github.com/plataformatec/devise/wiki/How-To:-Set-up-devise-to-use-email-OR-username-as-the-authentication-token to being able to login the user also by username.

Two behaviours:

- when using basic http auth, this strategy is ignored
- it doesn't work because apparently devise does another query, resulting in a 401:

Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"BvyWxmgXbm798wlB/4HYOKKlHj+mayeodYOmWZYbd7g=", "user"=>{"email"=>"masterkain", "password"=>"[FILTERED]"}, "commit"=>"Let me in!"}
User Load (24.4ms) SELECT `accounts`.* FROM `accounts` WHERE `accounts`.`deleted_at` IS NULL AND `accounts`.`type` IN ('User') AND (email = 'masterkain' OR screen_name = 'masterkain') LIMIT 1
User Load (0.8ms) SELECT `accounts`.* FROM `accounts` WHERE `accounts`.`deleted_at` IS NULL AND `accounts`.`type` IN ('User') AND `accounts`.`email` = 'masterkain' LIMIT 1
Completed 401 Unauthorized in 68ms