Module: Sinatra::Security::Identification
- Defined in:
- lib/sinatra/security/identification.rb
Overview
The identification module is mixed into Sinatra::Security::User. The API loosely applies to Ohm, although it will work with ActiveRecord.
If you wish to override any of these, it’s as simple as defining your own method in your User class.
Instance Method Summary collapse
-
#authenticate(login, password) ⇒ User?
Finds the User matching the given login / password combination.
-
#find_by_login(login) ⇒ User?
Used internally by User::authenticate to find the user given the ‘:email` value.
Instance Method Details
#authenticate(login, password) ⇒ User?
Finds the User matching the given login / password combination.
28 29 30 31 32 33 34 |
# File 'lib/sinatra/security/identification.rb', line 28 def authenticate(login, password) if user = find_by_login(login) if Sinatra::Security::Password::Hashing.check(password, user.crypted_password) user end end end |
#find_by_login(login) ⇒ User?
Used internally by User::authenticate to find the user given the ‘:email` value.
45 46 47 |
# File 'lib/sinatra/security/identification.rb', line 45 def find_by_login(login) find(__LOGIN_FIELD__ => login).first end |