1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

split send_reset_password_instructions into two parts for better hooking

This commit is contained in:
aditya-kapoor 2014-05-05 13:41:08 +05:30
parent a3fc587c24
commit c8fcbde2af

View file

@ -45,14 +45,10 @@ module Devise
# Resets reset password token and send reset password instructions by email.
# Returns the token sent in the e-mail.
def send_reset_password_instructions
raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)
token = set_reset_password_token
send_reset_password_instruction_notification(token)
self.reset_password_token = enc
self.reset_password_sent_at = Time.now.utc
self.save(validate: false)
send_devise_notification(:reset_password_instructions, raw, {})
raw
token
end
# Checks if the reset password token sent is within the limit time.
@ -90,6 +86,20 @@ module Devise
def after_password_reset
end
def set_reset_password_token
raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)
self.reset_password_token = enc
self.save(validate: false)
raw
end
def send_reset_password_instruction_notification(token)
self.reset_password_sent_at = Time.now.utc
self.save(validate: false)
send_devise_notification(:reset_password_instructions, token, {})
end
module ClassMethods
# Attempt to find a user by password reset token. If a user is found, return it
# If a user is not found, return nil