Module: Merb::Authentication::Mixins::SaltedUser::InstanceMethods

Defined in:
lib/merb-auth-more/mixins/salted_user.rb

Instance Method Summary collapse

Instance Method Details

#authenticated?(password) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/merb-auth-more/mixins/salted_user.rb', line 58

def authenticated?(password)
  crypted_password == encrypt(password)
end

#encrypt(password) ⇒ Object



62
63
64
# File 'lib/merb-auth-more/mixins/salted_user.rb', line 62

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

#encrypt_passwordObject



70
71
72
73
74
# File 'lib/merb-auth-more/mixins/salted_user.rb', line 70

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

#password_required?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/merb-auth-more/mixins/salted_user.rb', line 66

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