Skip to content
Snippets Groups Projects
Commit 0a808c2f authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Allow WS preview links to preview hidden pages

When a hidden page is previewed in the Backend,
the PreviewSimulator has a valid BE_USER object
in place. However, when a preview link is generated,
the PreviewUser does not have a group, thus the PreviewSimulator
is not activated.

For this reason, the check if the PreviewSimulator
is active, needs to consider if we are in an offline workspace

Resolves: #102216
Releases: main, 12.4
Change-Id: I95aadaad1de69ce6eed91acd82f4d42171a6500d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81901


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent cc5c9bfd
Branches
Tags
No related merge requests found
......@@ -49,7 +49,11 @@ class PreviewSimulator implements MiddlewareInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if ($this->context->getPropertyFromAspect('backend.user', 'isLoggedIn', false)) {
$isLoggedIn = $this->context->getPropertyFromAspect('backend.user', 'isLoggedIn', false);
$isOfflineWorkspace = $this->context->getPropertyFromAspect('workspace', 'isOffline', false);
// When previewing a workspace with the preview link, the PreviewUserAuthentication is NOT marked as
// "isLoggedIn" as it does not have a valid user ID. For this reason, we also check if the Workspace is offline. See WorkspacePreview middleware
if ($isLoggedIn || $isOfflineWorkspace) {
$pageArguments = $request->getAttribute('routing', null);
if (!$pageArguments instanceof PageArguments) {
return GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
......@@ -69,7 +73,6 @@ class PreviewSimulator implements MiddlewareInterface
$simulatingDate = $this->simulateDate($request);
$simulatingGroup = $this->simulateUserGroup($request);
$showHiddenRecords = $visibilityAspect->includeHidden();
$isOfflineWorkspace = $this->context->getPropertyFromAspect('workspace', 'id', 0) > 0;
$isPreview = $simulatingDate || $simulatingGroup || $showHiddenRecords || $showHiddenPages || $isOfflineWorkspace || $rootlineRequiresPreviewFlag;
if ($this->context->hasAspect('frontend.preview')) {
$previewAspect = $this->context->getAspect('frontend.preview');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment