FrontendUser::getCurrentUser()
\nn\t3::FrontendUser()->getCurrentUser();
Get array with the data of the current FE user.
\nn\t3::FrontendUser()->getCurrentUser();
Copied!
| @return array
Source Code
public function getCurrentUser()
{
if (!$this->isLoggedIn()) return [];
$user = $this->getFrontendUser();
if ($user) {
return $user->user ?? [];
}
// Ohne Frontend könnten wir uns z.B. in einer Middleware befinden. Nach AUTH sind die Daten evtl im Aspect.
$context = GeneralUtility::makeInstance(Context::class);
$userAspect = $context->getAspect('frontend.user');
if (!$userAspect) return [];
$usergroupUids = array_column($this->resolveUserGroups( $userAspect->get('groupIds') ), 'uid');
// Daten zu Standard-Darstellung normalisieren
return [
'uid' => $userAspect->get('id'),
'username' => $userAspect->get('username'),
'usergroup' => join(',', $usergroupUids)
] ?? [];
}
Copied!