-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(#4848) - Return only isVisible Tags, unless admin #4879
feat(#4848) - Return only isVisible Tags, unless admin #4879
Conversation
@@ -166,6 +167,7 @@ export default function () { | |||
slug: "tag", | |||
position: _.random(0, 100000), | |||
// relatedTagIds: [], | |||
isActive: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should isActive
be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooooops.... 😅
query.isVisible = { $ne: false }; | ||
} else if (shouldIncludeInvisible === true && context.userHasPermission(["owner", "admin"], shopId)) { | ||
query.isVisible = { $in: [false, true] }; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If shouldIncludeInvisible === true
but you're not an admin user, you will end up getting the invisible
and visible
tags.
What's even more interesting, if shouldIncludeDeleted = true
you can see deleted tags as well.
The logic in the function needs a bit of a rework. I think you should check if the user is an admin or not, then decide if they get to see isVisible:true
or isDeleted:true
tags. Then for everyone else, they don't get to see invisible or deleted products.
if isAdmin
shouldIncludeInvisible (add proper flags to query)
shouldIncludeDeleted (add proper flags to query)
else
only show visible and not delete tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see a single tag marked as isVisible=false
for the following query as both an admin and guest when shouldIncludeInvisible=false
"hats" was marked as isVisible = false
tag(slugOrId: "hats") {
name
slug
isVisible
displayTitle
}
I think you need to add this same login to the tag
(singular) query as well.
👍 |
Resolves #4848
Impact: minor
Type: feature
Issue
The current Tags query returns all in the collection, even if a tag's
isVisible
is set to false. To make sure the public cannot view the tag listing pages of certain tags, the Tags query should default to only returningisVisible
tags.Solution
shouldIncludeInvisible
parameter to the main query, set tofalse
by defaultshouldIncludeInvisible
can return all tagsBreaking changes
None
Testing
tag
andtags
queries