summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-03-20 13:49:51 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-03-22 15:39:54 +0000
commitf742010257b0aa00a999ef5e20a17c15f980f4c1 (patch)
tree88a1eda1d61483e3790cbf133c92f82795ddfbed
parente3bf4931de8a1c180f68fe99a7667a993711de59 (diff)
downloadgitlab-ce-f742010257b0aa00a999ef5e20a17c15f980f4c1.tar.gz
Tracks the number of failed attempts made by a user trying to authenticate with any external authentication method
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb10
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"]