2020-05-04 02:10:10 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
class GitAccessDesign < GitAccess
|
2020-07-21 14:09:45 -04:00
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
|
2020-05-04 02:10:10 -04:00
|
|
|
def check(_cmd, _changes)
|
|
|
|
check_protocol!
|
|
|
|
check_can_create_design!
|
|
|
|
|
|
|
|
success_result
|
|
|
|
end
|
|
|
|
|
2020-07-21 14:09:45 -04:00
|
|
|
override :push_ability
|
|
|
|
def push_ability
|
|
|
|
:create_design
|
|
|
|
end
|
|
|
|
|
2020-05-04 02:10:10 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def check_protocol!
|
|
|
|
if protocol != 'web'
|
|
|
|
raise ::Gitlab::GitAccess::ForbiddenError, "Designs are only accessible using the web interface"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_can_create_design!
|
2020-07-21 14:09:45 -04:00
|
|
|
unless user_can_push?
|
2020-05-04 02:10:10 -04:00
|
|
|
raise ::Gitlab::GitAccess::ForbiddenError, "You are not allowed to manage designs of this project"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Gitlab::GitAccessDesign.prepend_mod_with('Gitlab::GitAccessDesign')
|