diff --git a/lib/devise/models/authenticatable.rb b/lib/devise/models/authenticatable.rb index 54db258a..69f1324c 100644 --- a/lib/devise/models/authenticatable.rb +++ b/lib/devise/models/authenticatable.rb @@ -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? diff --git a/lib/devise/models/lockable.rb b/lib/devise/models/lockable.rb index fa6fcd70..35d3dc4d 100644 --- a/lib/devise/models/lockable.rb +++ b/lib/devise/models/lockable.rb @@ -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