Skip to content

Commit cdb1227

Browse files
committed
check page visibility
1 parent 4d10526 commit cdb1227

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Controller/FrontendPageController.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ public function indexAction(Request $request)
6969
throw new NotFoundHttpException();
7070
}
7171

72+
if ($this->getSnapshotVisibility($page) != PageInterface::VISIBILITY_PUBLIC) {
73+
74+
if (false === $this->get('security.context')->isGranted('ROLE_USER')) {
75+
throw new AccessDeniedException();
76+
}
77+
}
78+
7279
$updatedAt = $phpCache->get(sprintf('page_%s_created_at', $page->getId()));
7380
$cacheKey = $request->getLocale().$request->getPathInfo();
7481

@@ -442,6 +449,17 @@ public function getPageHelper()
442449
return $this->container->get('networking_init_cms.helper.page_helper');
443450
}
444451

452+
/**
453+
* @param PageSnapshotInterface $page
454+
* @return mixed
455+
*/
456+
public function getSnapshotVisibility(PageSnapshotInterface $page){
457+
458+
$jsonObject = json_decode($page->getVersionedData());
459+
460+
return $jsonObject->visibility;
461+
}
462+
445463
/**
446464
* @param PageSnapshotInterface $page
447465
* @return bool

0 commit comments

Comments
 (0)