redmine-0.9-stable-r3695-login_case_insensitive.patch

Case insensitive login patch for the Redmine 0.9-stable - Stanislav German-Evtushenko, 2010-04-29 13:25

Download (1.18 KB)

View differences:

app/models/user.rb (working copy)
53 53
  attr_protected :login, :admin, :password, :password_confirmation, :hashed_password, :group_ids
54 54
	
55 55
  validates_presence_of :login, :firstname, :lastname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
56
  validates_uniqueness_of :login, :if => Proc.new { |user| !user.login.blank? }
56
  validates_uniqueness_of :login, :if => Proc.new { |user| !user.login.blank? }, :case_sensitive => false
57 57
  validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }, :case_sensitive => false
58 58
  # Login must contain lettres, numbers, underscores only
59 59
  validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
......
96 96
  def self.try_to_login(login, password)
97 97
    # Make sure no one can sign in with an empty password
98 98
    return nil if password.to_s.empty?
99
    user = find(:first, :conditions => ["login=?", login])
99
    user = find(:first, :conditions => ["LOWER(login) = ?", login.to_s.downcase])
100 100
    if user
101 101
      # user is already in local database
102 102
      return nil if !user.active?