diff options
author | http://jneen.net/ <jneen@jneen.net> | 2017-03-10 00:59:19 +0300 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2017-03-10 00:59:19 +0300 |
commit | 90d924dc390693892a596659aa1a38b0432f6e40 (patch) | |
tree | b89f68182c96abbb9b92bf2b1eef489456619684 | |
parent | 66f204e0f0dd74df3409547bea2cec98c8947f2c (diff) |
reverse the logic and use a clearer name
-rw-r--r-- | lib/gitlab/user_access.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb index 3078b134bb3..f260c0c535f 100644 --- a/lib/gitlab/user_access.rb +++ b/lib/gitlab/user_access.rb @@ -8,7 +8,7 @@ module Gitlab end def can_do_action?(action) - return false if no_user_or_blocked? + return false unless can_access_git? @permission_cache ||= {} @permission_cache[action] ||= user.can?(action, project) @@ -19,7 +19,7 @@ module Gitlab end def allowed? - return false if no_user_or_blocked? + return false unless can_access_git? if user.requires_ldap_check? && user.try_obtain_ldap_lease return false unless Gitlab::LDAP::Access.allowed?(user) @@ -29,7 +29,7 @@ module Gitlab end def can_push_to_branch?(ref) - return false if no_user_or_blocked? + return false unless can_access_git? if project.protected_branch?(ref) return true if project.empty_repo? && project.user_can_push_to_empty_repo?(user) @@ -44,7 +44,7 @@ module Gitlab end def can_merge_to_branch?(ref) - return false if no_user_or_blocked? + return false unless can_access_git? if project.protected_branch?(ref) access_levels = project.protected_branches.matching(ref).map(&:merge_access_levels).flatten @@ -55,15 +55,15 @@ module Gitlab end def can_read_project? - return false if no_user_or_blocked? + return false unless can_access_git? user.can?(:read_project, project) end private - def no_user_or_blocked? - user.nil? || !user.can?(:access_git) + def can_access_git? + user && user.can?(:access_git) end end end |