2017-12-21 17:36:29 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2012-03-19 20:09:22 +00:00
|
|
|
# After each sign in, if resource responds to failed_attempts, sets it to 0
|
|
|
|
# This is only triggered when the user is explicitly set (with set_user)
|
2014-02-25 16:42:55 +00:00
|
|
|
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
|
2012-03-19 20:09:22 +00:00
|
|
|
if record.respond_to?(:failed_attempts) && warden.authenticated?(options[:scope])
|
2016-07-13 14:13:14 +00:00
|
|
|
unless record.failed_attempts.to_i.zero?
|
|
|
|
record.failed_attempts = 0
|
|
|
|
record.save(validate: false)
|
|
|
|
end
|
2012-03-19 20:09:22 +00:00
|
|
|
end
|
|
|
|
end
|