hobo_files/plugin/lib/hobo/user.rb in hobo-0.6.4 vs hobo_files/plugin/lib/hobo/user.rb in hobo-0.7.0
- old
+ new
@@ -69,13 +69,13 @@
# Authenticates a user by their login name and unencrypted password. Returns the user or nil.
def authenticate(login, password)
u = find(:first, :conditions => ["#{@login_attr} = ?", login]) # need to get the salt
if u && u.authenticated?(password)
- if u.respond_to?(:last_login_at) || u.respond_to?(:logins_count)
+ if u.respond_to?(:last_login_at) || u.respond_to?(:login_count)
u.last_login_at = Time.now if u.respond_to?(:last_login_at)
- u.logins_count = (u.logins_count.to_i + 1) if u.respond_to?(:logins_count)
+ u.login_count = (u.login_count.to_i + 1) if u.respond_to?(:login_count)
u.save
end
u
else
nil
@@ -124,10 +124,10 @@
protected
# Before filter that encrypts the password before having it stored in the database.
def encrypt_password
return if password.blank?
- self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if salt.blank?
self.crypted_password = encrypt(password)
end
# Is a password required for login? (or do we have an empty password?)
def password_required?