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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
476 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 RequestAccessService < Members::BaseService
def execute(source)
2016-11-03 12:29:30 +05:30
raise Gitlab::Access::AccessDeniedError unless can_request_access?(source)
source.members.create(
access_level: Gitlab::Access::DEVELOPER,
user: current_user,
2020-05-24 23:13:21 +05:30
requested_at: Time.current.utc)
2016-11-03 12:29:30 +05:30
end
private
def can_request_access?(source)
2018-03-27 19:54:05 +05:30
can?(current_user, :request_access, source)
2016-11-03 12:29:30 +05:30
end
end
end