Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5c0d670b
Commit
5c0d670b
authored
Apr 07, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid listing snippets in GraphQL when user profile is private
parent
a8a3056b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
app/graphql/resolvers/users/snippets_resolver.rb
app/graphql/resolvers/users/snippets_resolver.rb
+7
-0
changelogs/unreleased/58270-fj-fix-graphql-query-and-profile-status.yml
...eleased/58270-fj-fix-graphql-query-and-profile-status.yml
+5
-0
spec/graphql/resolvers/users/snippets_resolver_spec.rb
spec/graphql/resolvers/users/snippets_resolver_spec.rb
+12
-2
No files found.
app/graphql/resolvers/users/snippets_resolver.rb
View file @
5c0d670b
...
...
@@ -5,6 +5,7 @@ module Resolvers
module
Users
class
SnippetsResolver
<
BaseResolver
include
ResolvesSnippets
include
Gitlab
::
Allowable
alias_method
:user
,
:object
...
...
@@ -14,6 +15,12 @@ module Resolvers
private
def
resolve_snippets
(
_args
)
return
Snippet
.
none
unless
Ability
.
allowed?
(
current_user
,
:read_user_profile
,
user
)
super
end
def
snippet_finder_params
(
args
)
super
.
merge
(
author:
user
)
end
...
...
changelogs/unreleased/58270-fj-fix-graphql-query-and-profile-status.yml
0 → 100644
View file @
5c0d670b
---
title
:
Avoid listing snippets through GraphQL when user profile is private
merge_request
:
58739
author
:
type
:
fixed
spec/graphql/resolvers/users/snippets_resolver_spec.rb
View file @
5c0d670b
...
...
@@ -75,9 +75,19 @@ RSpec.describe Resolvers::Users::SnippetsResolver do
end
.
to
raise_error
(
GraphQL
::
CoercionError
)
end
end
context
'when user profile is private'
do
it
'does not return snippets for that user'
do
expect
(
resolve_snippets
(
obj:
other_user
)).
to
contain_exactly
(
other_personal_snippet
,
other_project_snippet
)
other_user
.
update!
(
private_profile:
true
)
expect
(
resolve_snippets
(
obj:
other_user
)).
to
be_empty
end
end
end
def
resolve_snippets
(
args:
{})
resolve
(
described_class
,
args:
args
,
ctx:
{
current_user:
c
urrent_user
},
obj:
current_user
)
def
resolve_snippets
(
args:
{}
,
context_user:
current_user
,
obj:
current_user
)
resolve
(
described_class
,
args:
args
,
ctx:
{
current_user:
c
ontext_user
},
obj:
obj
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment