Module: Shield::Model::ClassMethods
- Defined in:
- lib/shield.rb
Instance Method Summary collapse
- #authenticate(username, password) ⇒ Object
- #fetch(login) ⇒ Object
- #is_valid_password?(user, password) ⇒ Boolean
Instance Method Details
#authenticate(username, password) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/shield.rb', line 77 def authenticate(username, password) user = fetch(username) if user and is_valid_password?(user, password) return user end end |
#fetch(login) ⇒ Object
85 86 87 |
# File 'lib/shield.rb', line 85 def fetch(login) raise FetchMissing, "#{self}.fetch not implemented" end |
#is_valid_password?(user, password) ⇒ Boolean
89 90 91 |
# File 'lib/shield.rb', line 89 def is_valid_password?(user, password) Shield::Password.check(password, user.crypted_password) end |