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:
parent
4fc41dd68a
commit
e04c5ba977
2 changed files with 12 additions and 6 deletions
|
@ -37,7 +37,7 @@ module Devise
|
|||
def unlock_access!
|
||||
if_access_locked do
|
||||
self.locked_at = nil
|
||||
self.failed_attempts = 0
|
||||
self.failed_attempts = 0 if self.respond_to?(:failed_attempts=)
|
||||
self.unlock_token = nil if self.respond_to?(:unlock_token=)
|
||||
save(:validate => false)
|
||||
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
|
||||
|
|
|
@ -68,8 +68,14 @@ module Devise
|
|||
unlock_strategy = options[:unlock_strategy] ||
|
||||
(respond_to?(:unlock_strategy) ? self.unlock_strategy : :both)
|
||||
|
||||
unless unlock_strategy == :none
|
||||
apply_schema :failed_attempts, Integer, :default => 0
|
||||
apply_schema :unlock_token, String if [:both, :email].include?(unlock_strategy)
|
||||
end
|
||||
|
||||
if [:both, :email].include?(unlock_strategy)
|
||||
apply_schema :unlock_token, String
|
||||
end
|
||||
|
||||
apply_schema :locked_at, DateTime
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue