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

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

View file

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