Persist unlock token before triggering mailer

This commit is contained in:
Marcelo Silveira 2012-06-11 17:52:10 -03:00
parent 6dd7ccee68
commit fe0f6e96b3
1 changed files with 7 additions and 3 deletions

View File

@ -38,11 +38,11 @@ module Devise
self.locked_at = Time.now.utc
if unlock_strategy_enabled?(:email)
generate_unlock_token
generate_unlock_token!
send_unlock_instructions
else
save(:validate => false)
end
save(:validate => false)
end
# Unlock a user by cleaning locked_at and failed_attempts.
@ -123,6 +123,10 @@ module Devise
self.unlock_token = self.class.unlock_token
end
def generate_unlock_token!
generate_unlock_token && save(:validate => false)
end
# Tells if the lock is expired if :time unlock strategy is active
def lock_expired?
if unlock_strategy_enabled?(:time)