Browse Source

Friendly response when the LDAP connection fails.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8911 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/1.4.0
Jean-Philippe Lang 12 years ago
parent
commit
3e3d7c8d4f

+ 3
- 0
app/controllers/account_controller.rb View File

else else
authenticate_user authenticate_user
end end
rescue AuthSourceException => e
logger.error "An error occured when authenticating #{params[:username]}: #{e.message}"
render_error :message => e.message
end end


# Log out current user and redirect to welcome page # Log out current user and redirect to welcome page

+ 4
- 0
app/models/auth_source.rb View File

# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


# Generic exception for when the AuthSource can not be reached
# (eg. can not connect to the LDAP)
class AuthSourceException < Exception; end

class AuthSource < ActiveRecord::Base class AuthSource < ActiveRecord::Base
include Redmine::Ciphering include Redmine::Ciphering



+ 2
- 2
app/models/auth_source_ldap.rb View File

logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
return attrs.except(:dn) return attrs.except(:dn)
end end
rescue Net::LDAP::LdapError => text
raise "LdapError: " + text
rescue Net::LDAP::LdapError => e
raise AuthSourceException.new(e.message)
end end


# test the connection to the LDAP # test the connection to the LDAP

+ 10
- 0
test/functional/account_controller_test.rb View File

:content => /Invalid user or password/ :content => /Invalid user or password/
end end


def test_login_should_rescue_auth_source_exception
source = AuthSource.create!(:name => 'Test')
User.find(2).update_attribute :auth_source_id, source.id
AuthSource.any_instance.stubs(:authenticate).raises(AuthSourceException.new("Something wrong"))

post :login, :username => 'jsmith', :password => 'jsmith'
assert_response 500
assert_error_tag :content => /Something wrong/
end

if Object.const_defined?(:OpenID) if Object.const_defined?(:OpenID)


def test_login_with_openid_for_existing_user def test_login_with_openid_for_existing_user

Loading…
Cancel
Save