Project

General

Profile

Actions

Bug #96381

closed

Frontend preview doesn't work on restricted pages

Added by Juergen Kussmann over 2 years ago. Updated over 1 year 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 #1

Updated by Oliver Hader over 2 years ago

  • Status changed from New to Accepted

Sounds reasonable to avoid initializing groups again...

Actions #2

Updated by Benni Mack over 2 years ago

Hey Jürgen,

I guess the one thing we should do is properly populate the UserGroups in the PreviewSimulator class. PreviewSimulator does not populate $fe_user->userGroups properly...

Actions #3

Updated by Gerrit Code Review over 2 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73121

Actions #4

Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73121

Actions #5

Updated by Gerrit Code Review over 2 years ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73121

Actions #6

Updated by Gerrit Code Review over 2 years ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73121

Actions #7

Updated by Gerrit Code Review over 2 years ago

Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73154

Actions #8

Updated by Benni Mack over 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #9

Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed
Actions #10

Updated by Oliver Bartsch over 1 year ago

  • Related to Bug #99718: Admin Panel Simulate user group added
Actions

Also available in: Atom PDF