about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorMathieu Brunot <mathieu.brunot@monogramm.io>2019-12-01 18:52:21 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-12-01 18:52:21 +0100
commitbd8dc9bd0c9857470f14189c15572cab18bf8ab1 (patch)
tree74084369418bccb2e79e6a8c0d5043565f83969d /app/models
parent911cc144815babf83ddf99f2daa3682021d401b8 (diff)
:sparkles: Add an LDAP Mail attribute config (#12053)
Signed-off-by: mathieu.brunot <mathieu.brunot@monogramm.io>
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/ldap_authenticable.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/concerns/ldap_authenticable.rb b/app/models/concerns/ldap_authenticable.rb
index 2d2e1edbb..e3f94bb6c 100644
--- a/app/models/concerns/ldap_authenticable.rb
+++ b/app/models/concerns/ldap_authenticable.rb
@@ -6,7 +6,7 @@ module LdapAuthenticable
   class_methods do
     def authenticate_with_ldap(params = {})
       ldap   = Net::LDAP.new(ldap_options)
-      filter = format(Devise.ldap_search_filter, uid: Devise.ldap_uid, email: params[:email])
+      filter = format(Devise.ldap_search_filter, uid: Devise.ldap_uid, mail: Devise.ldap_mail, email: params[:email])
 
       if (user_info = ldap.bind_as(base: Devise.ldap_base, filter: filter, password: params[:password]))
         ldap_get_user(user_info.first)
@@ -25,7 +25,7 @@ module LdapAuthenticable
       resource = joins(:account).find_by(accounts: { username: safe_username })
 
       if resource.blank?
-        resource = new(email: attributes[:mail].first, agreement: true, account_attributes: { username: safe_username }, admin: false, external: true, confirmed_at: Time.now.utc)
+        resource = new(email: attributes[Devise.ldap_mail.to_sym].first, agreement: true, account_attributes: { username: safe_username }, admin: false, external: true, confirmed_at: Time.now.utc)
         resource.save!
       end