Commit 4210d0f5 authored by Douwe Maan's avatar Douwe Maan

Skip email confirmation when updated via LDAP.

parent 20bc37ea
v 7.10.0 (unreleased) 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
- 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 ldap_email = ldap_user.email.last.to_s.downcase
if (user.email != ldap_email) return false if user.email == ldap_email
user.skip_reconfirmation!
user.update(email: ldap_email) user.update(email: ldap_email)
else
false
end
else
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