Post preview is broken in Lyra

I just went to preview a new post I was writing, and apparently previews is only for paying subscribers.

I identified where in the code this happens, but I’m just confused as to why it was made like this in the first place. Now I can’t preview my own posts (even if I sign in). The post access is set to public.

It’s the {{#if access}}, but if I remove that if statement, then there won’t be any gate on the paid posts.

Edit: An issue on GitHub was already made by another user. https://github.com/TryGhost/Lyra/issues/4

I’m guessing it’s an oversight because the access property is only set in the entry controller (used for rendering posts in collections and static pages)

But not in the preview controller (which renders… previews)

Thank you for your suggestion vik :slight_smile:

The access variable seems to always be set to paid, not taking into account what the individual posts’ post access is set to. From the Ghost Members documentation:

access

access is a variable that is calculated between the access level of the member viewing the post and the access level setting applied to the post. access will return true if the member’s access matches, or exceeds, the access level of the post.

You were right! :slight_smile:

The fix is post.access = !!post.html; in the preview.js file – tested on local ghost installation.

Edit: made a pull request on github https://github.com/TryGhost/Ghost/pull/11275

1 Like