Module: UsersAuthentication::InstanceMethods
- Defined in:
- lib/generators/fetty/authentication/templates/lib/users_authentication.rb
Instance Method Summary collapse
- #activated? ⇒ Boolean
- #clear_token! ⇒ Object
- #make_token! ⇒ Object
- #password_match?(pass) ⇒ Boolean
- #reset_password(new_pass, new_pass_conf) ⇒ Object
- #send_activation_mail ⇒ Object
- #send_forgot_password_instructions! ⇒ Object
Instance Method Details
#activated? ⇒ Boolean
57 58 59 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 57 def activated? !self.activated_at.nil? end |
#clear_token! ⇒ Object
65 66 67 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 65 def clear_token! self.update_attribute(:token, nil) end |
#make_token! ⇒ Object
61 62 63 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 61 def make_token! self.update_attribute(:token, generate_token) end |
#password_match?(pass) ⇒ Boolean
53 54 55 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 53 def password_match?(pass) self.password_hash == encrypt_password(pass) end |
#reset_password(new_pass, new_pass_conf) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 41 def reset_password(new_pass,new_pass_conf) self.password = new_pass self.password_confirmation = new_pass_conf self.save unless self.password_match?(new_pass) return Status::Error else self.clear_token! return Status::Valid end end |
#send_activation_mail ⇒ Object
32 33 34 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 32 def send_activation_mail UserMailer.user_activation(self).deliver end |
#send_forgot_password_instructions! ⇒ Object
36 37 38 39 |
# File 'lib/generators/fetty/authentication/templates/lib/users_authentication.rb', line 36 def send_forgot_password_instructions! self.make_token! UserMailer.user_forgot_password(self).deliver end |