From 4834fb74028d3c40991b622de30b1f550fec512d Mon Sep 17 00:00:00 2001 From: jicksta Date: Tue, 17 Feb 2009 17:32:55 -0700 Subject: [PATCH] downcase() the username when using a generated model's authenticate() class method. (usernames are stored downcase()d) --- generators/authenticated/templates/model.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/authenticated/templates/model.rb b/generators/authenticated/templates/model.rb index fd36fed..8534846 100644 --- a/generators/authenticated/templates/model.rb +++ b/generators/authenticated/templates/model.rb @@ -55,9 +55,9 @@ def active? # def self.authenticate(login, password) return nil if login.blank? || password.blank? - u = <% if options[:stateful] %>find_in_state :first, :active, :conditions => {:login => login}<% + u = <% if options[:stateful] %>find_in_state :first, :active, :conditions => {:login => login.downcase}<% elsif options[:include_activation] %>find :first, :conditions => ['login = ? and activated_at IS NOT NULL', login]<% - else %>find_by_login(login)<% end %> # need to get the salt + else %>find_by_login(login.downcase)<% end %> # need to get the salt u && u.authenticated?(password) ? u : nil end