Commit f7420102 authored by Tiago Botelho's avatar Tiago Botelho

Tracks the number of failed attempts made by a user trying to authenticate...

Tracks the number of failed attempts made by a user trying to authenticate with any external authentication method
parent e3bf4931
...@@ -18,6 +18,16 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -18,6 +18,16 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end end
end end
# Extend the standard implementation to also increment
# the number of failed sign in attempts
def failure
user = User.find_by_username(params[:username])
user&.increment_failed_attempts!
super
end
# Extend the standard message generation to accept our custom exception # Extend the standard message generation to accept our custom exception
def failure_message def failure_message
exception = env["omniauth.error"] exception = env["omniauth.error"]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment