Commit 7a73c974 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'ldap-email-update' into 'master'

Skip email confirmation when updated via LDAP.

Followup to https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/494, addresses https://dev.gitlab.org/gitlab/gitlabhq/issues/2203.

See merge request !363
parents 7ad1008e 4210d0f5
......@@ -2,6 +2,7 @@ v 7.10.0 (unreleased)
- Improve UI for next pages: Group LDAP sync, Project git hooks, Project share with groups, Admin -> Appearance settigns
- Default git hooks for new projects
- Fix LDAP group links page by using new group members route.
- Skip email confirmation when updated via LDAP.
v 7.9.0 (unreleased)
- Strip prefixes and suffixes from synced SSH keys:
......
......@@ -103,17 +103,14 @@ module Gitlab
# Update user email if it changed in LDAP
def update_email
if ldap_user.try(:email)
ldap_email = ldap_user.email.last.to_s.downcase
return false unless ldap_user.try(:email)
if (user.email != ldap_email)
user.update(email: ldap_email)
else
false
end
else
false
end
ldap_email = ldap_user.email.last.to_s.downcase
return false if user.email == ldap_email
user.skip_reconfirmation!
user.update(email: ldap_email)
end
def update_admin_status
......
......@@ -145,22 +145,22 @@ describe Gitlab::LDAP::Access do
end
it "should not update email if email attribute is not set" do
expect{ access.update_email }.to_not change(user, :unconfirmed_email)
expect{ access.update_email }.to_not change(user, :email)
end
it "should not update the email if the user has the same email in GitLab and in LDAP" do
entry['mail'] = [user.email]
expect{ access.update_email }.to_not change(user, :unconfirmed_email)
expect{ access.update_email }.to_not change(user, :email)
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['mail'] = [user.email.upcase]
expect{ access.update_email }.to_not change(user, :unconfirmed_email)
expect{ access.update_email }.to_not change(user, :email)
end
it "should update the email if the user email is different" do
entry['mail'] = ["new_email@example.com"]
expect{ access.update_email }.to change(user, :unconfirmed_email)
expect{ access.update_email }.to change(user, :email)
end
end
......
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