Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch devise lockable hook #275

Merged
merged 1 commit into from
Apr 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions core/lib/devise/hooks/lockable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# using current version https://github.com/plataformatec/devise/blob/e841c4c5ef826b6838b269d259170bb4fbca82f1/lib/devise/hooks/lockable.rb
# as 3-stable version https://github.com/plataformatec/devise/blob/3-stable/lib/devise/hooks/lockable.rb
# is using update_attribute which is not supported by Her
# 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)
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
if record.respond_to?(:failed_attempts) && warden.authenticated?(options[:scope])
unless record.failed_attempts.to_i.zero?
record.failed_attempts = 0
record.save(validate: false)
end
end
end