Module: Merb::Authentication::Mixins::SaltedUserWithAccount::InstanceMethods
- Defined in:
- lib/heedley-merb-auth-with-account/mixins/salted_user.rb
Instance Method Summary collapse
- #authenticated?(password, account) ⇒ Boolean
- #encrypt(password) ⇒ Object
- #encrypt_password ⇒ Object
- #password_required? ⇒ Boolean
Instance Method Details
#authenticated?(password, account) ⇒ Boolean
56 57 58 |
# File 'lib/heedley-merb-auth-with-account/mixins/salted_user.rb', line 56 def authenticated?(password, account) ( crypted_password == encrypt(password) ) && ( account == self.account.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_password ⇒ Object
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.login_param}--") if new_record? self.crypted_password = encrypt(password) end |
#password_required? ⇒ 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 |