]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
Tell users if the reason they can't login is because they haven't activated
[rails.git] / app / models / user.rb
index d6cff0f25856e0cc8f65ab12677ac6c75f347ed9..92d47d5ffab5e88117738f94b60fd596510c2d18 100644 (file)
@@ -24,11 +24,11 @@ class User < ActiveRecord::Base
   end
 
   def encrypt_password
-    self.pass_crypt = Digest::MD5.hexdigest(pass_crypt) if pass_crypt_confirmation
+    self.pass_crypt = Digest::MD5.hexdigest(pass_crypt) unless pass_crypt_confirmation.nil?
   end
 
-  def self.authenticate(email, passwd)
-    find(:first, :conditions => [ "email = ? AND pass_crypt = ? AND active = true", email, Digest::MD5.hexdigest(passwd)])
+  def self.authenticate(email, passwd, active = true)
+    find(:first, :conditions => [ "email = ? AND pass_crypt = ? AND active = ?", email, Digest::MD5.hexdigest(passwd), active])
   end 
 
   def self.authenticate_token(token)