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:
Diffstat (limited to 'app/controllers/concerns/authenticates_with_two_factor.rb')
-rw-r--r--app/controllers/concerns/authenticates_with_two_factor.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/controllers/concerns/authenticates_with_two_factor.rb b/app/controllers/concerns/authenticates_with_two_factor.rb
index 9fd86e6a7e0..41a3ee3e1c8 100644
--- a/app/controllers/concerns/authenticates_with_two_factor.rb
+++ b/app/controllers/concerns/authenticates_with_two_factor.rb
@@ -52,6 +52,14 @@ module AuthenticatesWithTwoFactor
elsif user && user.valid_password?(user_params[:password])
prompt_for_two_factor(user)
end
+ rescue ActiveRecord::RecordInvalid => e
+ # We expect User to always be valid.
+ # Otherwise, raise internal server error instead of unprocessable entity to improve observability/alerting
+ if e.record.is_a?(User)
+ raise e.message
+ else
+ raise e
+ end
end
private