diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-27 14:35:42 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-28 08:46:59 +0200 |
commit | 5f88aafbf697d791707938c9732ec2d86723252a (patch) | |
tree | db62c121772820183a356e37aa59b5b737f9a3a0 /app/finders/access_requests_finder.rb | |
parent | 924a6b7d33a245845071894de8d46d77bd44b52e (diff) | |
download | gitlab-ce-5f88aafbf697d791707938c9732ec2d86723252a.tar.gz |
Improve the logic in AccessRequestsFinder#execute & #execute!
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/finders/access_requests_finder.rb')
-rw-r--r-- | app/finders/access_requests_finder.rb | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/app/finders/access_requests_finder.rb b/app/finders/access_requests_finder.rb index 78fb7627741..79b0ba39e2c 100644 --- a/app/finders/access_requests_finder.rb +++ b/app/finders/access_requests_finder.rb @@ -7,23 +7,21 @@ class AccessRequestsFinder @source = source end - def execute(current_user, raise_error: false) - if cannot_see_access_requests?(current_user) - raise Gitlab::Access::AccessDeniedError if raise_error - - return [] - end - - source.requesters + def execute(*args) + execute!(*args) + rescue Gitlab::Access::AccessDeniedError + [] end def execute!(current_user) - execute(current_user, raise_error: true) + raise Gitlab::Access::AccessDeniedError unless can_see_access_requests?(current_user) + + source.requesters end private - def cannot_see_access_requests?(current_user) - !source || !current_user || !current_user.can?(:"admin_#{source.class.to_s.underscore}", source) + def can_see_access_requests?(current_user) + source && current_user && current_user.can?(:"admin_#{source.class.to_s.underscore}", source) end end |