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