summaryrefslogtreecommitdiff
path: root/lib/gitlab/graphql
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 09:08:01 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 09:08:01 +0000
commit17b91a3c6ab73fff087e91665e9afb8046cbf045 (patch)
tree04655a8630478d9846571875f69469f018d4bdcc /lib/gitlab/graphql
parentb3db40398ce9ad335270617e834fde96d46f90ea (diff)
downloadgitlab-ce-17b91a3c6ab73fff087e91665e9afb8046cbf045.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/graphql')
-rw-r--r--lib/gitlab/graphql/authorize/authorize_resource.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/gitlab/graphql/authorize/authorize_resource.rb b/lib/gitlab/graphql/authorize/authorize_resource.rb
index df60b9d8346..26e8c53032f 100644
--- a/lib/gitlab/graphql/authorize/authorize_resource.rb
+++ b/lib/gitlab/graphql/authorize/authorize_resource.rb
@@ -6,6 +6,8 @@ module Gitlab
module AuthorizeResource
extend ActiveSupport::Concern
+ RESOURCE_ACCESS_ERROR = "The resource that you are attempting to access does not exist or you don't have permission to perform this action"
+
class_methods do
def required_permissions
# If the `#authorize` call is used on multiple classes, we add the
@@ -38,8 +40,7 @@ module Gitlab
def authorize!(object)
unless authorized_resource?(object)
- raise Gitlab::Graphql::Errors::ResourceNotAvailable,
- "The resource that you are attempting to access does not exist or you don't have permission to perform this action"
+ raise_resource_not_avaiable_error!
end
end
@@ -61,6 +62,10 @@ module Gitlab
Ability.allowed?(current_user, ability, object, scope: :user)
end
end
+
+ def raise_resource_not_avaiable_error!
+ raise Gitlab::Graphql::Errors::ResourceNotAvailable, RESOURCE_ACCESS_ERROR
+ end
end
end
end