Module: AuthSlice::BaseModel::ClassMethods
- Defined in:
- app/models/base_model.rb
Instance Method Summary collapse
-
#authenticate(username, password) ⇒ Object
Authenticates a user by their username and unencrypted password.
-
#encrypt(password, salt) ⇒ Object
Encrypts some data with the salt.
Instance Method Details
#authenticate(username, password) ⇒ Object
Authenticates a user by their username and unencrypted password. Returns the user or nil.
70 71 72 73 |
# File 'app/models/base_model.rb', line 70 def authenticate(username, password) u = find_by_username(username) # need to get the salt u && u.authenticated?(password) ? u : nil end |
#encrypt(password, salt) ⇒ Object
Encrypts some data with the salt.
65 66 67 |
# File 'app/models/base_model.rb', line 65 def encrypt(password, salt) Digest::SHA1.hexdigest("--#{salt}--#{password}--") end |