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
|
|
|
|
|
2018-07-02 06:43:06 -04:00
|
|
|
if member.update(params)
|
2017-10-11 10:47:08 -04:00
|
|
|
after_execute(action: permission, old_access_level: old_access_level, 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
|