##// END OF EJS Templates
Friendly response when the LDAP connection fails....
Jean-Philippe Lang -
r8791:3e3d7c8d4f4f
parent child
Show More
@@ -29,6 +29,9 class AccountController < ApplicationController
29 29 else
30 30 authenticate_user
31 31 end
32 rescue AuthSourceException => e
33 logger.error "An error occured when authenticating #{params[:username]}: #{e.message}"
34 render_error :message => e.message
32 35 end
33 36
34 37 # Log out current user and redirect to welcome page
@@ -15,6 +15,10
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 # Generic exception for when the AuthSource can not be reached
19 # (eg. can not connect to the LDAP)
20 class AuthSourceException < Exception; end
21
18 22 class AuthSource < ActiveRecord::Base
19 23 include Redmine::Ciphering
20 24
@@ -40,8 +40,8 class AuthSourceLdap < AuthSource
40 40 logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
41 41 return attrs.except(:dn)
42 42 end
43 rescue Net::LDAP::LdapError => text
44 raise "LdapError: " + text
43 rescue Net::LDAP::LdapError => e
44 raise AuthSourceException.new(e.message)
45 45 end
46 46
47 47 # test the connection to the LDAP
@@ -51,6 +51,16 class AccountControllerTest < ActionController::TestCase
51 51 :content => /Invalid user or password/
52 52 end
53 53
54 def test_login_should_rescue_auth_source_exception
55 source = AuthSource.create!(:name => 'Test')
56 User.find(2).update_attribute :auth_source_id, source.id
57 AuthSource.any_instance.stubs(:authenticate).raises(AuthSourceException.new("Something wrong"))
58
59 post :login, :username => 'jsmith', :password => 'jsmith'
60 assert_response 500
61 assert_error_tag :content => /Something wrong/
62 end
63
54 64 if Object.const_defined?(:OpenID)
55 65
56 66 def test_login_with_openid_for_existing_user
General Comments 0
You need to be logged in to leave comments. Login now