Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-03-27 16:43:48 +0300
committerDouwe Maan <douwe@gitlab.com>2015-04-03 13:23:20 +0300
commitedc4a56d26792b5b5bac21f45948412675ad7ebb (patch)
tree5691320e58507e134a2f026f8f4e8054821edf50 /app/models/user.rb
parent9157985cfce1391973673ea278dc7506a90f8f53 (diff)
Allow admin to create public deploy keys that are accessible to any project.
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 515f29ea0ba..ea6b1367bbc 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -414,8 +414,16 @@ class User < ActiveRecord::Base
@ldap_identity ||= identities.find_by(["provider LIKE ?", "ldap%"])
end
+ def project_deploy_keys
+ DeployKey.in_projects(self.authorized_projects.pluck(:id))
+ end
+
def accessible_deploy_keys
- DeployKey.in_projects(self.authorized_projects.pluck(:id)).uniq
+ @accessible_deploy_keys ||= begin
+ key_ids = project_deploy_keys.pluck(:id)
+ key_ids.push(*DeployKey.are_public.pluck(:id))
+ DeployKey.where(id: key_ids)
+ end
end
def created_by