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? }
|
2017-03-31 08:54:38 -04:00
|
|
|
|
2017-04-06 17:06:42 -04:00
|
|
|
condition(:has_deploy_key) { @user.project_deploy_keys.exists?(id: @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
|