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:
authorPat Thoyts <patthoyts@users.sourceforge.net>2012-07-21 12:04:05 +0400
committerPat Thoyts <patthoyts@users.sourceforge.net>2012-07-21 12:04:05 +0400
commita2d244ec062f3348f6cd1c5218c6097402c5f562 (patch)
tree38d5bf8cf8989acb92142381052fc52b1d554c4c /app/controllers/omniauth_callbacks_controller.rb
parent9267cb04b0b3fdf127899c4b7e636dc27fac06d3 (diff)
Handle LDAP missing credentials error with a flash message.
If a user fails to provide a username or password to the LDAP login form then a 500 error is returned due to an exception being raised in omniauth-ldap. This gem has been amended to use the omniauth error propagation function (fail!) to pass this exception message to the registered omniauth failure handler so that the Rails application can handle it approriately. The failure function now knows about standard exceptions and no longer requires a specific check for the OmniAuth::Error exception added by commit f322975. This resolves issue #1077. Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Diffstat (limited to 'app/controllers/omniauth_callbacks_controller.rb')
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index fb759c371c4..d19931e93d7 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -3,13 +3,10 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
# Extend the standard message generation to accept our custom exception
def failure_message
exception = env["omniauth.error"]
- if exception.class == OmniAuth::Error
- error = exception.message
- else
- error = exception.error_reason if exception.respond_to?(:error_reason)
- error ||= exception.error if exception.respond_to?(:error)
- error ||= env["omniauth.error.type"].to_s
- end
+ error = exception.error_reason if exception.respond_to?(:error_reason)
+ error ||= exception.error if exception.respond_to?(:error)
+ error ||= exception.message if exception.respond_to?(:message)
+ error ||= env["omniauth.error.type"].to_s
error.to_s.humanize if error
end