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