correctly recognize bad LDAP credentials in test

- also raise when testing connection of an abstract auth source, avoiding wrong success messages
pull/3316/head
Jan Sandbrink 9 years ago
parent cbcebed95f
commit 07705ae1c4
  1. 2
      app/models/auth_source.rb
  2. 7
      app/models/ldap_auth_source.rb
  3. 5
      config/locales/en.yml

@ -40,7 +40,9 @@ class AuthSource < ActiveRecord::Base
def authenticate(_login, _password)
end
# implemented by a subclass, should raise when no connection is possible and not raise on success
def test_connection
raise I18n.t('auth_source.using_abstract_auth_source')
end
def auth_method_name

@ -53,10 +53,11 @@ class LdapAuthSource < AuthSource
# test the connection to the LDAP
def test_connection
ldap_con = initialize_ldap_con(account, account_password)
ldap_con.open {}
unless authenticate_dn(account, account_password)
raise I18n.t('auth_source.ldap_error', error_message: I18n.t('auth_source.ldap_auth_failed'))
end
rescue Net::LDAP::LdapError => text
raise 'LdapError: ' + text.to_s
raise I18n.t('auth_source.ldap_error', error_message: text.to_s)
end
def auth_method_name

@ -1091,6 +1091,11 @@ en:
label_keyboard_shortcut_focus_next_item: "Focus next list element (on some lists only)"
label_visible_elements: Visible elements
auth_source:
using_abstract_auth_source: "Can't use an abstract authentication source."
ldap_error: "LDAP-Error: %{error_message}"
ldap_auth_failed: "Could not authenticate at the LDAP-Server."
macro_execution_error: "Error executing the macro %{macro_name}"
macro_unavailable: "Macro %{macro_name} cannot be displayed."

Loading…
Cancel
Save