Module: Merb::Authentication::Mixins::SenileUser::InstanceMethods
- Defined in:
- lib/merb-auth-slice-password-reset/mixins/senile_user.rb
Overview
ClassMethods
Instance Method Summary collapse
- #generate_password_reset_code ⇒ Object
- #password_reset? ⇒ Boolean
- #reset_password! ⇒ Object
- #send_new_password ⇒ Object
-
#send_password_reset_notification ⇒ Object
Sends out the password reset notification.
Instance Method Details
#generate_password_reset_code ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/merb-auth-slice-password-reset/mixins/senile_user.rb', line 52 def generate_password_reset_code pwreset_key_success = false until pwreset_key_success self.password_reset_code = self.class.make_key self.save pwreset_key_success = self.errors.on(:password_reset_code).nil? ? true : false end end |
#password_reset? ⇒ Boolean
61 62 63 |
# File 'lib/merb-auth-slice-password-reset/mixins/senile_user.rb', line 61 def password_reset? ! self.password_reset_code.nil? end |
#reset_password! ⇒ Object
45 46 47 48 49 50 |
# File 'lib/merb-auth-slice-password-reset/mixins/senile_user.rb', line 45 def reset_password! self.password = self.password_confirmation = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )[0, 7] send_new_password self.password_reset_code = nil self.save end |
#send_new_password ⇒ Object
72 73 74 |
# File 'lib/merb-auth-slice-password-reset/mixins/senile_user.rb', line 72 def send_new_password deliver_password_reset_email(:new_password, :subject => (MaSPR[:new_password_subject] || "Your new password")) end |
#send_password_reset_notification ⇒ Object
Sends out the password reset notification. Used ‘Request to change your password’ as subject if MaSFP[:password_reset_subject]
is not set.
67 68 69 70 |
# File 'lib/merb-auth-slice-password-reset/mixins/senile_user.rb', line 67 def send_password_reset_notification generate_password_reset_code deliver_password_reset_email(:password_reset, :subject => (MaSPR[:password_reset_subject] || "Request to change your password")) end |