Module: Merb::Authentication::Mixins::SaltedUserWithAccount::InstanceMethods

Defined in:
lib/heedley-merb-auth-with-account/mixins/salted_user.rb

Instance Method Summary collapse

Instance Method Details

#authenticated?(password, account) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user.rb', line 56

def authenticated?(password, )
  ( crypted_password == encrypt(password) ) && (  == self..title )
end

#encrypt(password) ⇒ Object



60
61
62
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user.rb', line 60

def encrypt(password)
  self.class.encrypt(password, salt)
end

#encrypt_passwordObject



68
69
70
71
72
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user.rb', line 68

def encrypt_password
  return if password.blank?
  self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{Merb::Authentication::Strategies::Basic::Base.}--") if new_record?
  self.crypted_password = encrypt(password)
end

#password_required?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user.rb', line 64

def password_required?
  crypted_password.blank? || !password.blank?
end