2016-07-28 17:28:56 +00:00
|
|
|
module Members
|
2017-10-11 14:47:08 +00:00
|
|
|
class RequestAccessService < Members::BaseService
|
2018-02-16 14:10:22 +00:00
|
|
|
def execute(source)
|
2016-09-22 09:11:33 +00:00
|
|
|
raise Gitlab::Access::AccessDeniedError unless can_request_access?(source)
|
2016-07-28 17:28:56 +00:00
|
|
|
|
|
|
|
source.members.create(
|
|
|
|
access_level: Gitlab::Access::DEVELOPER,
|
|
|
|
user: current_user,
|
|
|
|
requested_at: Time.now.utc)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-09-22 09:11:33 +00:00
|
|
|
def can_request_access?(source)
|
2018-02-16 14:10:22 +00:00
|
|
|
can?(current_user, :request_access, source)
|
2016-07-28 17:28:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|