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

More work with unlock_strategy equals to none.

This commit is contained in:
José Valim 2010-03-30 01:58:06 +02:00
parent 4fc41dd68a
commit e04c5ba977
2 changed files with 12 additions and 6 deletions

View file

@ -37,8 +37,8 @@ module Devise
def unlock_access!
if_access_locked do
self.locked_at = nil
self.failed_attempts = 0
self.unlock_token = nil if self.respond_to?(:unlock_token=)
self.failed_attempts = 0 if self.respond_to?(:failed_attempts=)
self.unlock_token = nil if self.respond_to?(:unlock_token=)
save(:validate => false)
end
end
@ -75,7 +75,7 @@ module Devise
# is locked, it should never be allowed.
def valid_for_authentication?
return :locked if access_locked?
return super unless persisted?
return super if !persisted? || self.class.unlock_strategy == :none
if result = super
self.failed_attempts = 0

View file

@ -68,9 +68,15 @@ module Devise
unlock_strategy = options[:unlock_strategy] ||
(respond_to?(:unlock_strategy) ? self.unlock_strategy : :both)
apply_schema :failed_attempts, Integer, :default => 0
apply_schema :unlock_token, String if [:both, :email].include?(unlock_strategy)
apply_schema :locked_at, DateTime
unless unlock_strategy == :none
apply_schema :failed_attempts, Integer, :default => 0
end
if [:both, :email].include?(unlock_strategy)
apply_schema :unlock_token, String
end
apply_schema :locked_at, DateTime
end
# Overwrite with specific modification to create your own schema.