2016-07-28 13:30:34 -04:00
|
|
|
module Members
|
2017-10-11 10:47:08 -04:00
|
|
|
class ApproveAccessRequestService < Members::BaseService
|
2018-02-16 09:10:22 -05:00
|
|
|
def execute(access_requester, skip_authorization: false, skip_log_audit_event: false)
|
|
|
|
raise Gitlab::Access::AccessDeniedError unless skip_authorization || can_update_access_requester?(access_requester)
|
2016-07-28 13:30:34 -04:00
|
|
|
|
|
|
|
access_requester.access_level = params[:access_level] if params[:access_level]
|
|
|
|
access_requester.accept_request
|
|
|
|
|
2018-02-16 09:10:22 -05:00
|
|
|
after_execute(member: access_requester, skip_log_audit_event: skip_log_audit_event)
|
2017-10-11 10:47:08 -04:00
|
|
|
|
2016-07-28 13:30:34 -04:00
|
|
|
access_requester
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-02-16 09:10:22 -05:00
|
|
|
def can_update_access_requester?(access_requester)
|
|
|
|
can?(current_user, update_member_permission(access_requester), access_requester)
|
2016-07-28 13:30:34 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|