diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /app/services/members/create_service.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'app/services/members/create_service.rb')
-rw-r--r-- | app/services/members/create_service.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/app/services/members/create_service.rb b/app/services/members/create_service.rb index 3e809b11024..0cc62e661a3 100644 --- a/app/services/members/create_service.rb +++ b/app/services/members/create_service.rb @@ -4,9 +4,12 @@ module Members class CreateService < Members::BaseService BlankInvitesError = Class.new(StandardError) TooManyInvitesError = Class.new(StandardError) + MembershipLockedError = Class.new(StandardError) DEFAULT_INVITE_LIMIT = 100 + attr_reader :membership_locked + def initialize(*args) super @@ -17,18 +20,22 @@ module Members def execute validate_invite_source! - validate_invites! + validate_invitable! add_members enqueue_onboarding_progress_action result - rescue BlankInvitesError, TooManyInvitesError => e + rescue BlankInvitesError, TooManyInvitesError, MembershipLockedError => e error(e.message) end + def single_member + members.last + end + private - attr_reader :source, :errors, :invites, :member_created_namespace_id + attr_reader :source, :errors, :invites, :member_created_namespace_id, :members def invites_from_params params[:user_ids] @@ -38,7 +45,7 @@ module Members raise ArgumentError, s_('AddMember|No invite source provided.') unless invite_source.present? end - def validate_invites! + def validate_invitable! raise BlankInvitesError, blank_invites_message if invites.blank? return unless user_limit && invites.size > user_limit @@ -52,7 +59,7 @@ module Members end def add_members - members = source.add_users( + @members = source.add_users( invites, params[:access_level], expires_at: params[:expires_at], |