I am trying to add a very simple strategy for development, and it does not seem to work. Here is the code I'm trying to use
#config/initializers/devise.rb Devise.setup do |config| config.orm = :mongo_mapper config.warden do |manager| manager.strategies.add(:auto_login_strategy) do def valid? params[:auto_login] end def authenticate! u = User.find(:first) u.nil? ? fail!("No created users") : success!(u) end end manager.default_strategies(:scope=>:user).unshift :auto_login_strategy end end
The code should check the parameters for the "auto_login" parameter, and if it is present, find the first user that it can and write to it. I completely skipped security measures to just run a basic test case. When I try to enter the controller with before_filter authenticate_user! (i.e. localhost:3000/test?auto_login=true ), it cannot log in and redirect me to the login page. What am I doing wrong?
source share