Commit 7ab46831 authored by Marin Jankovski's avatar Marin Jankovski

Merge branch 'ldap_email_downcase' into 'master'

Fix LDAP email upper case bug
parents 95ef8f97 cd3fb5ff
......@@ -2,6 +2,7 @@ v 6.9.0
- Add support for closing Jira tickets with commits and MR
- Template for Merge Request description can be added in project settings
- Jenkins CI service
- Fix LDAP email upper case bug
v 6.8.0
- Customise sign-in page with custom text and logo
......
......@@ -63,7 +63,7 @@ module Gitlab
gitlab_user = ::User.where(provider: 'ldap', extern_uid: uid).last
if gitlab_user && ldap_user && ldap_user.email
ldap_email = ldap_user.email.last
ldap_email = ldap_user.email.last.to_s.downcase
if (gitlab_user.email != ldap_email)
gitlab_user.update(email: ldap_email)
......
......@@ -50,6 +50,14 @@ describe Gitlab::LDAP::Access do
updated.should == false
end
it "should not update the email if the user has the same email GitLab and in LDAP, but with upper case in LDAP" do
entry = Net::LDAP::Entry.new
entry['mail'] = [user_ldap.email.upcase]
Gitlab::LDAP::Adapter.any_instance.stub(:user) { Gitlab::LDAP::Person.new(entry) }
updated = access.update_email(user_ldap)
updated.should == false
end
it "should update the email if the user email is different" do
entry = Net::LDAP::Entry.new
entry['mail'] = ["new_email@example.com"]
......
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