Commit 3eb36672 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'refactor-member-add-user-for-ee' into 'master'

Refactor Member#add_user for GitLab EE

See merge request gitlab-org/gitlab-ce!23119
parents 3438587c 0aa386f7
...@@ -152,11 +152,13 @@ class Member < ActiveRecord::Base ...@@ -152,11 +152,13 @@ class Member < ActiveRecord::Base
return member unless can_update_member?(current_user, member) return member unless can_update_member?(current_user, member)
member.attributes = { set_member_attributes(
created_by: member.created_by || current_user, member,
access_level: access_level, access_level,
expires_at: expires_at current_user: current_user,
} expires_at: expires_at,
ldap: ldap
)
if member.request? if member.request?
::Members::ApproveAccessRequestService.new( ::Members::ApproveAccessRequestService.new(
...@@ -175,6 +177,18 @@ class Member < ActiveRecord::Base ...@@ -175,6 +177,18 @@ class Member < ActiveRecord::Base
# rubocop: enable CodeReuse/ServiceClass # rubocop: enable CodeReuse/ServiceClass
end end
# Populates the attributes of a member.
#
# This logic resides in a separate method so that EE can extend this logic,
# without having to patch the `add_user` method directly.
def set_member_attributes(member, access_level, current_user: nil, expires_at: nil, ldap: false)
member.attributes = {
created_by: member.created_by || current_user,
access_level: access_level,
expires_at: expires_at
}
end
def add_users(source, users, access_level, current_user: nil, expires_at: nil) def add_users(source, users, access_level, current_user: nil, expires_at: nil)
return [] unless users.present? return [] unless users.present?
......
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