diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-11-16 15:31:08 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-11-16 15:31:23 +0300 |
commit | a9765fb47fbbd1e1070434fc06cc76b25a42caa6 (patch) | |
tree | 30ffc7e93c5721c6ac7743daf6f705a4566efa98 /app/models | |
parent | 721478123068c6718ec73c72a7b7d32c00c816df (diff) |
Introduce has_access_to? so that we could reuse it
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7383#note_18439108
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/deploy_key.rb | 6 | ||||
-rw-r--r-- | app/models/user.rb | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb index 503398f5cca..aaacbd28470 100644 --- a/app/models/deploy_key.rb +++ b/app/models/deploy_key.rb @@ -21,7 +21,11 @@ class DeployKey < Key self.private? end + def has_access_to?(project) + projects.include?(project) + end + def can_push_to?(project) - can_push? && projects.include?(project) + can_push? && has_access_to?(project) end end diff --git a/app/models/user.rb b/app/models/user.rb index 3813df6684e..0e96ad88638 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -501,6 +501,10 @@ class User < ActiveRecord::Base several_namespaces? || admin end + def has_access_to?(project) + can?(:read_project, project) + end + def can?(action, subject) Ability.allowed?(self, action, subject) end |