Commit edaabaf4 authored by James Lopez's avatar James Lopez

Updated code based on feeddback

parent 84e40a7d
...@@ -12,9 +12,11 @@ module GroupSaml ...@@ -12,9 +12,11 @@ module GroupSaml
end end
def execute def execute
Identity.transaction do
identity.destroy! identity.destroy!
remove_group_access remove_group_access
end end
end
private private
......
...@@ -33,6 +33,10 @@ module API ...@@ -33,6 +33,10 @@ module API
def scim_error!(message:) def scim_error!(message:)
error!({ with: EE::Gitlab::Scim::Error }.merge(detail: message), 409) error!({ with: EE::Gitlab::Scim::Error }.merge(detail: message), 409)
end end
def email_taken?(email, identity)
User.by_any_email(email.downcase).where.not(id: identity.user.id).count > 0
end
end end
resource :Users do resource :Users do
...@@ -92,8 +96,7 @@ module API ...@@ -92,8 +96,7 @@ module API
elsif parsed_hash[:extern_uid] elsif parsed_hash[:extern_uid]
identity.update(parsed_hash.slice(:extern_uid)) identity.update(parsed_hash.slice(:extern_uid))
else else
scim_error!(message: 'Email has already been taken') if parsed_hash[:email] && scim_error!(message: 'Email has already been taken') if email_taken?(parsed_hash[:email], identity)
User.by_any_email(parsed_hash[:email].downcase).where.not(id: identity.user.id).count > 0
result = ::Users::UpdateService.new(identity.user, result = ::Users::UpdateService.new(identity.user,
parsed_hash.except(:extern_uid, :provider) parsed_hash.except(:extern_uid, :provider)
......
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