2021-06-28 14:08:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Members
|
|
|
|
module Projects
|
|
|
|
class CreatorService < Members::CreatorService
|
|
|
|
def self.access_levels
|
2022-02-23 01:18:49 -05:00
|
|
|
Gitlab::Access.sym_options_with_owner
|
2021-06-28 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_update_member?
|
2022-03-28 20:09:12 -04:00
|
|
|
super || current_user.can?(:update_project_member, member) || adding_the_creator_as_owner_in_a_personal_project?
|
2021-06-28 14:08:39 -04:00
|
|
|
end
|
|
|
|
|
2022-03-28 20:09:12 -04:00
|
|
|
def adding_the_creator_as_owner_in_a_personal_project?
|
2021-06-28 14:08:39 -04:00
|
|
|
# this condition is reached during testing setup a lot due to use of `.add_user`
|
2022-03-28 20:09:12 -04:00
|
|
|
member.project.personal_namespace_holder?(member.user) && member.new_record?
|
2021-06-28 14:08:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|