Skip to content

Commit

Permalink
[#43 state:resolved] removing email case changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Croak committed Feb 9, 2009
1 parent 69dccd5 commit 4ba8d8e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.textile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
h2. 0.4.5 (unreleased)

* removed email downcasing. (local-part is case sensitive per RFC5321)

h2. 0.4.4 (2/2/2009)

* Added a generator for Cucumber features
Expand Down
8 changes: 2 additions & 6 deletions lib/clearance/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def self.included(model)
validates_uniqueness_of :email, :case_sensitive => false
validates_format_of :email, :with => %r{.+@.+\..+}

before_save :initialize_salt, :encrypt_password, :initialize_token, :downcase_email
before_save :initialize_salt, :encrypt_password, :initialize_token

def self.authenticate(email, password)
user = find(:first, :conditions => ['LOWER(email) = ?', email.to_s.downcase])
user = find(:first, :conditions => ['email = ?', email.to_s])
user && user.authenticated?(password) ? user : nil
end

Expand Down Expand Up @@ -104,10 +104,6 @@ def password_required?
encrypted_password.blank? || !password.blank?
end

def downcase_email
self.email = email.to_s.downcase
end

end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/clearance/test/unit/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def self.included(unit_test)
end
end

should "store email in lower case" do
should "store email in exact case" do
user = Factory(:user, :email => "John.Doe@example.com")
assert_equal "john.doe@example.com", user.email
assert_equal "John.Doe@example.com", user.email
end
end

Expand Down Expand Up @@ -97,8 +97,8 @@ def self.included(unit_test)
assert @user.authenticated?(@password)
end

should "authenticate with good credentials, email in uppercase" do
assert User.authenticate(@user.email.upcase, @password)
should "authenticate with good credentials" do
assert User.authenticate(@user.email, @password)
assert @user.authenticated?(@password)
end

Expand Down

0 comments on commit 4ba8d8e

Please sign in to comment.