2018-07-17 16:50:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-11 14:47:08 +00:00
|
|
|
module Members
|
|
|
|
class UpdateService < Members::BaseService
|
|
|
|
# returns the updated member
|
|
|
|
def execute(member, permission: :update)
|
2018-02-16 14:10:22 +00:00
|
|
|
raise Gitlab::Access::AccessDeniedError unless can?(current_user, action_member_permission(permission, member), member)
|
2017-10-11 14:47:08 +00:00
|
|
|
|
|
|
|
old_access_level = member.human_access
|
|
|
|
|
2018-07-02 10:43:06 +00:00
|
|
|
if member.update(params)
|
2017-10-11 14:47:08 +00:00
|
|
|
after_execute(action: permission, old_access_level: old_access_level, member: member)
|
2018-12-11 18:15:10 +00:00
|
|
|
|
|
|
|
# Deletes only confidential issues todos for guests
|
|
|
|
enqueue_delete_todos(member) if downgrading_to_guest?
|
2017-10-11 14:47:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
member
|
|
|
|
end
|
2018-12-11 18:15:10 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def downgrading_to_guest?
|
|
|
|
params[:access_level] == Gitlab::Access::GUEST
|
|
|
|
end
|
2017-10-11 14:47:08 +00:00
|
|
|
end
|
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
Members::UpdateService.prepend_if_ee('EE::Members::UpdateService')
|