Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-03-20 16:49:51 +0300
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-03-22 18:39:54 +0300
commitf742010257b0aa00a999ef5e20a17c15f980f4c1 (patch)
tree88a1eda1d61483e3790cbf133c92f82795ddfbed /app/controllers/omniauth_callbacks_controller.rb
parente3bf4931de8a1c180f68fe99a7667a993711de59 (diff)
Tracks the number of failed attempts made by a user trying to authenticate with any external authentication method
Diffstat (limited to 'app/controllers/omniauth_callbacks_controller.rb')
-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"]