Project

General

Profile

Actions

Bug #96381

closed

Frontend preview doesn't work on restricted pages

Added by Juergen Kussmann almost 3 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
Start date:
2021-12-17
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

The frontend-preview of restricted pages doesn't work.

An example:
The TYPO3-page 'mytypo3page' is restricted by the fe_groups-record with UID 4884. When i click the frontend-preview-button in the TYPO3-backend-module 'page', than
TYPO3 is calling this URL:
https://mytypo3domain.com/mytypo3page?ADMCMD_simUser=4884

The result in an 404-pageNotFound-error, because of this:
1. TYPO3\CMS\Frontend\Middleware\PreviewSimulator::simulateUserGroup will create the aspect 'frontend.user' (with an logged-in FE-user).
2. Later (during the FE-rendering) TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::fetch_the_id will initialize the FE-userGroups, by calling '$this->initUserGroups()'.
3. TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::initUserGroups overrides the already existing aspect 'frontend.user' (with an 'empty' FE-user).

So, we must fix the bug in TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::initUserGroups:

    public function initUserGroups()
    {
        if ($this->isInPreviewMode() &&
            $this->context->getAspect('frontend.user')->isLoggedIn() ) {
            // do NOT create userAspect! Because that would overwrite the already
            // existing userAspect, which was created in TYPO3\CMS\Frontend\Middleware\PreviewSimulator::process()
            return;
        }
        $userAspect = $this->fe_user->createUserAspect((bool)$this->loginAllowedInBranch);
        $this->context->setAspect('frontend.user', $userAspect);
    }

Files


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #99718: Admin Panel Simulate user groupClosed2023-01-25

Actions
Actions

Also available in: Atom PDF