| Module | Cms::Authentication::Model::ClassMethods |
| In: |
lib/cms/authentication/model.rb
|
# File lib/cms/authentication/model.rb, line 20
20: def authenticate(login, password)
21: u = find_by_login(login) # need to get the salt
22: u && u.authenticated?(password) && !u.expired? ? u : nil
23: end
Method to make it easy to change a user‘s password from the console, not used in the app
# File lib/cms/authentication/model.rb, line 26
26: def change_password(login, new_password)
27: find_by_login(login).change_password(new_password)
28: end
# File lib/cms/authentication/model.rb, line 30
30: def make_token
31: secure_digest(Time.now, (1..10).map{ rand.to_s })
32: end
# File lib/cms/authentication/model.rb, line 34
34: def password_digest(password, salt)
35: key = '8771d0d9bef6f1091b723d2e701a17c811d69b26'
36: digest = key
37: 10.times do
38: digest = secure_digest(digest, salt, password, key)
39: end
40: digest
41: end