2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
class DeployKeyPolicy < BasePolicy
|
|
|
|
with_options scope: :subject, score: 0
|
|
|
|
condition(:private_deploy_key) { @subject.private? }
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-09-10 17:25:29 +05:30
|
|
|
condition(:has_deploy_key) { @user.project_deploy_keys.exists?(id: @subject.id) }
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
rule { anonymous }.prevent_all
|
|
|
|
|
|
|
|
rule { admin }.enable :update_deploy_key
|
|
|
|
rule { private_deploy_key & has_deploy_key }.enable :update_deploy_key
|
|
|
|
end
|