diff options
Diffstat (limited to 'lib/gitlab/graphql')
-rw-r--r-- | lib/gitlab/graphql/authorize/authorize_resource.rb | 9 |
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 |