2018-07-24 06:00:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
class DeployKeyPolicy < BasePolicy
|
2017-04-06 17:06:42 -04:00
|
|
|
with_options scope: :subject, score: 0
|
|
|
|
condition(:private_deploy_key) { @subject.private? }
|
2019-12-11 19:07:43 -05:00
|
|
|
condition(:has_deploy_key) { @user.project_deploy_keys.any? { |pdk| pdk.id.eql?(@subject.id) } }
|
2017-03-31 08:54:38 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
rule { anonymous }.prevent_all
|
|
|
|
|
|
|
|
rule { admin }.enable :update_deploy_key
|
|
|
|
rule { private_deploy_key & has_deploy_key }.enable :update_deploy_key
|
2017-03-31 08:54:38 -04:00
|
|
|
end
|