Skip to content
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

#get helper retrieve pages or posts correctly with tier restrictions #16250

Closed
1 task done
cathysarisky opened this issue Feb 8, 2023 · 5 comments
Closed
1 task done
Labels
bug [triage] something behaving unexpectedly stale [triage] Issues that were closed to to lack of traction

Comments

@cathysarisky
Copy link
Contributor

Issue Summary

When I {{#get}} either pages or posts and attempt to loop over them with {{#foreach}}, if those pages/posts are restricted to a specific tier, I don't get any {{content}} except the public preview (if any), whether the user has access to those items or not.

Steps to Reproduce

Create one a tier (link to Stripe to make this possible). I tested in Stripe's test mode.
Create posts/pages that are restricted to only that tier. (I also created some free and "paid member" posts.)
Create a new page template that includes the following code:

   <div class="gh-inner">
        {{#get "pages" filter="tags:[grabme]"}}
        {{#foreach pages}}
        <hr>
        <div>
            POST NAME: {{title}} <a href="{{url}}">LINK TO POST</a>

            {{#if access }} {{content}} 
            {{else}}You can't read this!, but try anyway: <p>{{content}}</p>
            {{/if}}

            <p>Check post's specific status:
            {{#has visibility="public"}}
                This content is free</p>
            {{/has}}

            {{#has visibility="paid"}}
            This content is paid</p>
            {{/has}}

            {{#has visibility="filter"}}
            Filtered content for {{tier}}.</p>
            {{/has}}

        </div>

        {{/foreach}}
        {{/get}}
    </div>

Create a new page (public) that uses the template with code above.

For a public post, I get the content at the top and the "This content is free" message. For the paid post, I get the content at the top and the "This content is paid" message, if I'm logged in with a paid user. For a 'paid members' post viewed as free user, I see the "You can't read this" message, followed by any public preview and CTA for that post. That's all good.

However, when my loop goes over a post restricted to a specific tier, I get the "You can't read this" message, whether or not my test user has access. I get the public preview (if any), but I don't get the protected content, NOR do I get a CTA, nor does the "Filtered content for {{tier}} message show up." That's not the expected behavior. I'd expect to see the content if my test user is allowed to see that content when navigating to the post directly, or to see a CTA and the message about filtering if my user is not allowed to see that content.

Ghost Version

Ghost Pro

Node.js Version

Ghost Pro

How did you install Ghost?

Ghost Pro

Database type

MySQL 8

Browser & OS version

No response

Relevant log / error output

No response

Code of Conduct

  • I agree to be friendly and polite to people in this repository
@github-actions github-actions bot added the needs:triage [triage] this needs to be triaged by the Ghost team label Feb 8, 2023
@daniellockyer daniellockyer added bug [triage] something behaving unexpectedly and removed needs:triage [triage] this needs to be triaged by the Ghost team labels Mar 9, 2023
@daniellockyer
Copy link
Member

That doesn't look right! A PR to fix this would be welcome 🙂

@cathysarisky
Copy link
Contributor Author

I'd like to help, but I find the Ghost core a bit difficult to navigate. Can you point me in the right direction to start bug hunting?

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2023

Our bot has automatically marked this issue as stale because there has not been any activity here in some time.

The issue will be closed soon if there are no further updates, however we ask that you do not post comments to keep the issue open if you are not actively working on a PR.

We keep the issue list minimal so we can keep focus on the most pressing issues. Closed issues can always be reopened if a new contributor is found. Thank you for understanding 🙂

@github-actions github-actions bot added the stale [triage] Issues that were closed to to lack of traction label Jul 7, 2023
@daniellockyer daniellockyer removed the stale [triage] Issues that were closed to to lack of traction label Jul 10, 2023
@RohitLakh
Copy link

Upon debugging

When we make the call from the template which @cathysarisky provided we see no information about the tier.

image

So when we add include="tiers" in the get helper we can at least see the tier information in the frontend. (Hello is the name of the tier)

image
  • The tier information is not fetched due to no include="tiers" being given in the get helper due to which in content-gating.js the access is blocked because the post doesn't have the tier information.
image

Now let's say we are adding tier information also in include but then in content-gating.js, this checks where we are validating visibility with the member object fails.

image

Here when we go to the actual page (not getting data using get helper) with a user who has access to the tier, the member object has a products object which contains the tier information, whereas when getting data from the get helper, we don't see the products object inside the member but do see the subscriptions object which contains tier inside it (which is there in both the cases)

The next step can be

  • Include tier information as default in withRelated.
  • When getting a member object from get helper, also add the products object or use the subscriptions -> tier objects as a backup. Help here with deciding will be appreciated as I don't have much context about the codebase.

These changes will have an effect on other aspects of Ghost (which I don't have much info about), and will require some go-ahead to make them and create a PR.

cc: @daniellockyer @kevinansfield

Copy link
Contributor

Our bot has automatically marked this issue as stale because there has not been any activity here in some time.

The issue will be closed soon if there are no further updates, however we ask that you do not post comments to keep the issue open if you are not actively working on a PR.

We keep the issue list minimal so we can keep focus on the most pressing issues. Closed issues can always be reopened if a new contributor is found. Thank you for understanding 🙂

@github-actions github-actions bot added the stale [triage] Issues that were closed to to lack of traction label Nov 27, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [triage] something behaving unexpectedly stale [triage] Issues that were closed to to lack of traction
Projects
None yet
Development

No branches or pull requests

3 participants