diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-03-20 16:49:51 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-03-22 18:39:54 +0300 |
commit | f742010257b0aa00a999ef5e20a17c15f980f4c1 (patch) | |
tree | 88a1eda1d61483e3790cbf133c92f82795ddfbed /app | |
parent | e3bf4931de8a1c180f68fe99a7667a993711de59 (diff) |
Tracks the number of failed attempts made by a user trying to authenticate with any external authentication method
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/omniauth_callbacks_controller.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index fff249577a2..fed8ba3ce28 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -18,6 +18,16 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController 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 def failure_message exception = env["omniauth.error"] |