gitlab-org--gitlab-foss/app/services/members/request_access_service.rb
Rémy Coutable 1c88d92b3f Improve Member services
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-02-27 16:02:22 +01:00

18 lines
441 B
Ruby

module Members
class RequestAccessService < Members::BaseService
def execute(source)
raise Gitlab::Access::AccessDeniedError unless can_request_access?(source)
source.members.create(
access_level: Gitlab::Access::DEVELOPER,
user: current_user,
requested_at: Time.now.utc)
end
private
def can_request_access?(source)
can?(current_user, :request_access, source)
end
end
end