Adding symbols only on validate
This commit is contained in:
parent
68de34c03e
commit
033e91b7b9
|
@ -78,6 +78,10 @@ module Devise
|
|||
block_given? ? yield : true
|
||||
end
|
||||
|
||||
def unauthenticated_message
|
||||
:invalid
|
||||
end
|
||||
|
||||
def active_for_authentication?
|
||||
true
|
||||
end
|
||||
|
@ -214,4 +218,4 @@ module Devise
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -92,7 +92,6 @@ module Devise
|
|||
self.failed_attempts += 1
|
||||
if attempts_exceeded?
|
||||
lock_access! unless access_locked?
|
||||
return :locked
|
||||
else
|
||||
save(:validate => false)
|
||||
end
|
||||
|
@ -100,6 +99,14 @@ module Devise
|
|||
end
|
||||
end
|
||||
|
||||
def unauthenticated_message
|
||||
if self.respond_to?(:failed_attempts) && attempts_exceeded?
|
||||
:locked
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def attempts_exceeded?
|
||||
|
|
|
@ -56,6 +56,7 @@ module Devise
|
|||
def after_token_authentication
|
||||
end
|
||||
|
||||
|
||||
module ClassMethods
|
||||
def find_for_token_authentication(conditions)
|
||||
find_for_authentication(:authentication_token => conditions[token_authentication_key])
|
||||
|
@ -70,4 +71,4 @@ module Devise
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,14 +23,20 @@ module Devise
|
|||
result = resource && resource.valid_for_authentication?(&block)
|
||||
|
||||
case result
|
||||
when String, Symbol
|
||||
when Symbol, String
|
||||
ActiveSupport::Deprecation.warn "valid_for_authentication should return a boolean value"
|
||||
fail!(result)
|
||||
false
|
||||
when TrueClass
|
||||
return false
|
||||
end
|
||||
|
||||
if result
|
||||
decorate(resource)
|
||||
true
|
||||
else
|
||||
result
|
||||
if resource
|
||||
fail!(resource.unauthenticated_message)
|
||||
end
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue