Commit a2d244ec authored by Pat Thoyts's avatar Pat Thoyts

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 f322975c.

This resolves issue #1077.
Signed-off-by: default avatarPat Thoyts <patthoyts@users.sourceforge.net>
parent 9267cb04
...@@ -13,7 +13,7 @@ gem "devise", "~> 2.1.0" ...@@ -13,7 +13,7 @@ gem "devise", "~> 2.1.0"
gem "grit", :git => "https://github.com/gitlabhq/grit.git", :ref => "7f35cb98ff17d534a07e3ce6ec3d580f67402837" gem "grit", :git => "https://github.com/gitlabhq/grit.git", :ref => "7f35cb98ff17d534a07e3ce6ec3d580f67402837"
gem "gitolite", :git => "https://github.com/gitlabhq/gitolite-client.git", :ref => "9b715ca8bab6529f6c92204a25f84d12f25a6eb0" gem "gitolite", :git => "https://github.com/gitlabhq/gitolite-client.git", :ref => "9b715ca8bab6529f6c92204a25f84d12f25a6eb0"
gem "pygments.rb", :git => "https://github.com/gitlabhq/pygments.rb.git", :ref => "2cada028da5054616634a1d9ca6941b65b3ce188" gem "pygments.rb", :git => "https://github.com/gitlabhq/pygments.rb.git", :ref => "2cada028da5054616634a1d9ca6941b65b3ce188"
gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "7edf27d0281e09561838122982c16b7e62181f44" gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e"
gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git" gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git"
gem 'grack', :git => "https://github.com/gitlabhq/grack.git" gem 'grack', :git => "https://github.com/gitlabhq/grack.git"
gem "linguist", "~> 1.0.0", :git => "https://github.com/gitlabhq/linguist.git" gem "linguist", "~> 1.0.0", :git => "https://github.com/gitlabhq/linguist.git"
......
...@@ -42,8 +42,8 @@ GIT ...@@ -42,8 +42,8 @@ GIT
GIT GIT
remote: https://github.com/gitlabhq/omniauth-ldap.git remote: https://github.com/gitlabhq/omniauth-ldap.git
revision: 7edf27d0281e09561838122982c16b7e62181f44 revision: f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e
ref: 7edf27d0281e09561838122982c16b7e62181f44 ref: f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e
specs: specs:
omniauth-ldap (1.0.2) omniauth-ldap (1.0.2)
net-ldap (~> 0.2.2) net-ldap (~> 0.2.2)
......
...@@ -3,13 +3,10 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -3,13 +3,10 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
# Extend the standard message generation to accept our custom exception # Extend the standard message generation to accept our custom exception
def failure_message def failure_message
exception = env["omniauth.error"] exception = env["omniauth.error"]
if exception.class == OmniAuth::Error error = exception.error_reason if exception.respond_to?(:error_reason)
error = exception.message error ||= exception.error if exception.respond_to?(:error)
else error ||= exception.message if exception.respond_to?(:message)
error = exception.error_reason if exception.respond_to?(:error_reason) error ||= env["omniauth.error.type"].to_s
error ||= exception.error if exception.respond_to?(:error)
error ||= env["omniauth.error.type"].to_s
end
error.to_s.humanize if error error.to_s.humanize if error
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment