🐛 Fixed post content gating error for themes using old api

refs https://github.com/TryGhost/Team/issues/1071

We switched to using tiers pivot table that stores list of tiers with access to post when visibility is set to `tiers`. For themes using v3 API while having posts restricted to specific tiers visibility, the post data will not include the list of tiers, which caused an unexpected error while trying to determine post access from tiers list. This change blocks access to post if specific tiers visibility is enabled without data available for list of tiers on post.
This commit is contained in:
Rishabh 2022-02-11 12:26:19 +05:30
parent c80e68b93a
commit 3ccd3601b3

View File

@ -42,6 +42,9 @@ function checkPostAccess(post, member) {
let visibility = post.visibility === 'paid' ? 'status:-free' : post.visibility;
if (visibility === 'tiers') {
if (!post.tiers) {
return BLOCK_ACCESS;
}
visibility = post.tiers.map((product) => {
return `product:${product.slug}`;
}).join(',');