Frontend user 

The frontend.user frontend request attribute provides the \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication 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
  }
}
Copied!