Issue Bug Closed

#90070isLoggedIn not set in PSR-15 Middleware

Thomas Kieslich 01/08/20, 13:54 updated 01/09/20, 16:56

Description

/** @var UserAspect $frontendUserAspect */
        $frontendUserAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user');
        $id = $frontendUserAspect->get('id');
        $loggedIn = $GLOBALS['TSFE']->loginUser;
        $loggedInNew = $frontendUserAspect->isLoggedIn();

With this Code in a Middleware Script i get a ID (User is logged in) but no loggedIn Flag (false)
I found out that in the FrontendUserAuthentication Object the groupData Property is empty.
If i run GLOBALS[‘TSFE’]->initUserGroups(); before, it works fine.
It should work without manual Initialization. This Code works fine:

        $GLOBALS['TSFE']->initUserGroups();
        /** @var UserAspect $frontendUserAspect */
        $frontendUserAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user');
        $id = $frontendUserAspect->get('id');
        $loggedIn = $GLOBALS['TSFE']->loginUser;
        $loggedInNew = $frontendUserAspect->isLoggedIn();

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.