debian-mirror-gitlab/app/services/members/approve_access_request_service.rb

25 lines
833 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
module Members
2018-03-27 19:54:05 +05:30
class ApproveAccessRequestService < Members::BaseService
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-11-03 12:29:30 +05:30
access_requester.access_level = params[:access_level] if params[:access_level]
access_requester.accept_request
2018-03-27 19:54:05 +05:30
after_execute(member: access_requester, skip_log_audit_event: skip_log_audit_event)
2016-11-03 12:29:30 +05:30
access_requester
end
private
2018-03-27 19:54:05 +05:30
def can_update_access_requester?(access_requester)
can?(current_user, update_member_permission(access_requester), access_requester)
2018-03-17 18:26:18 +05:30
end
2016-11-03 12:29:30 +05:30
end
end
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
Members::ApproveAccessRequestService.prepend_mod_with('Members::ApproveAccessRequestService')