mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Simplify active_for_authentication? checking.
This commit is contained in:
parent
a816e538ab
commit
0439c35198
2 changed files with 5 additions and 13 deletions
|
@ -27,7 +27,7 @@ module Devise
|
|||
#
|
||||
# == active_for_authentication?
|
||||
#
|
||||
# Before authenticating a user and in each request, Devise checks if your model is active by
|
||||
# After authenticating a user and in each request, Devise checks if your model is active by
|
||||
# calling model.active_for_authentication?. This method is overwriten by other devise modules. For instance,
|
||||
# :confirmable overwrites .active_for_authentication? to only return true if your model was confirmed.
|
||||
#
|
||||
|
@ -61,12 +61,7 @@ module Devise
|
|||
# However, you should not overwrite this method, you should overwrite active_for_authentication?
|
||||
# and inactive_message instead.
|
||||
def valid_for_authentication?
|
||||
authenticated = block_given? ? yield : true
|
||||
if authenticated
|
||||
active_for_authentication? || inactive_message
|
||||
else
|
||||
authenticated
|
||||
end
|
||||
block_given? ? yield : true
|
||||
end
|
||||
|
||||
def active_for_authentication?
|
||||
|
|
|
@ -79,12 +79,10 @@ module Devise
|
|||
# if the user can login or not (wrong password, etc)
|
||||
unlock_access! if lock_expired?
|
||||
|
||||
case (result = super)
|
||||
when Symbol
|
||||
return result
|
||||
when TrueClass
|
||||
if super
|
||||
self.failed_attempts = 0
|
||||
save(:validate => false)
|
||||
true
|
||||
else
|
||||
self.failed_attempts ||= 0
|
||||
self.failed_attempts += 1
|
||||
|
@ -94,9 +92,8 @@ module Devise
|
|||
else
|
||||
save(:validate => false)
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
Loading…
Reference in a new issue