From fd07c74578c5d6d790502cd6c5da9d8ff6e9efea Mon Sep 17 00:00:00 2001 From: Gabe da Silveira Date: Tue, 2 Aug 2011 12:08:38 -0700 Subject: [PATCH] Refactor to use method and override --- lib/devise/models/confirmable.rb | 5 +++++ lib/devise/models/recoverable.rb | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/devise/models/confirmable.rb b/lib/devise/models/confirmable.rb index fd6d7f9d..2251adf3 100644 --- a/lib/devise/models/confirmable.rb +++ b/lib/devise/models/confirmable.rb @@ -127,6 +127,11 @@ module Devise generate_confirmation_token && save(:validate => false) end + def after_password_reset + super + confirm! unless confirmed? + end + module ClassMethods # Attempt to find a user by it's email. If a record is found, send new # confirmation instructions to it. If not user is found, returns a new user diff --git a/lib/devise/models/recoverable.rb b/lib/devise/models/recoverable.rb index 77c30736..07ec764c 100644 --- a/lib/devise/models/recoverable.rb +++ b/lib/devise/models/recoverable.rb @@ -31,7 +31,7 @@ module Devise self.password_confirmation = new_password_confirmation if valid? clear_reset_password_token - confirm! if respond_to?(:confirmed?) && !confirmed? + after_password_reset end save @@ -93,6 +93,9 @@ module Devise self.reset_password_sent_at = nil if respond_to?(:reset_password_sent_at=) end + def after_password_reset + end + module ClassMethods # Attempt to find a user by it's email. If a record is found, send new # password instructions to it. If not user is found, returns a new user