Frontend user
The
frontend. frontend request attribute provides the
\TYPO3\ object.
The topic is described in depth in chapter Authentication.
Example:
EXT:my_extension/Classes/Service/MyService.php
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Service;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
final class MyService
{
public function doSomethingToFrontendUser(
ServerRequestInterface $request,
): void {
/** @var FrontendUserAuthentication $frontendUserAuthentification */
$frontendUserAuthentification = $request->getAttribute('frontend.user');
$frontendUserAuthentification->fetchGroupData($request);
// do something
}
}
Tip
The frontend user id and groups are available from the User aspect.