Module: Huberry::Authentication::ModelMethods::InstanceMethods
- Defined in:
- lib/huberry/authentication/model_methods.rb
Instance Method Summary collapse
- #authenticated?(password) ⇒ Boolean
- #password_changed? ⇒ Boolean
- #reload_with_authentication(*args) ⇒ Object
- #reset_password(new_password = nil) ⇒ Object
- #reset_password!(new_password = nil) ⇒ Object
Instance Method Details
#authenticated?(password) ⇒ Boolean
41 42 43 |
# File 'lib/huberry/authentication/model_methods.rb', line 41 def authenticated?(password) send(self.class.[:hashed_password_field]) == self.class.digest(password.to_s + send(self.class.[:salt_field]).to_s) end |
#password_changed? ⇒ Boolean
45 46 47 |
# File 'lib/huberry/authentication/model_methods.rb', line 45 def password_changed? !!@password_changed end |
#reload_with_authentication(*args) ⇒ Object
49 50 51 52 |
# File 'lib/huberry/authentication/model_methods.rb', line 49 def reload_with_authentication(*args) reload_without_authentication(*args) @password_changed = false end |
#reset_password(new_password = nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/huberry/authentication/model_methods.rb', line 54 def reset_password(new_password = nil) new_password = generate_salt[0..7] if new_password.blank? send("#{self.class.authentication_options[:salt_field]}=", nil) send("#{self.class.authentication_options[:password_field]}=", new_password) send("#{self.class.authentication_options[:password_field]}_confirmation=", new_password) @password_changed = true end |
#reset_password!(new_password = nil) ⇒ Object
62 63 64 65 |
# File 'lib/huberry/authentication/model_methods.rb', line 62 def reset_password!(new_password = nil) reset_password(new_password) save end |