Closed
Description
Symfony version(s) affected
6.4.1
Description
In production environment i get regularly this exception in logs :
Uncaught PHP Exception TypeError: "Symfony\Component\Security\Http\Authentication\AuthenticationUtils::getLastUsername(): Return value must be of type string, null returned" at AuthenticationUtils.php
How to reproduce
I don't know exactly what trigger this exception
Possible Solution
Changing the return type of the method :
public function getLastUsername(): ?string
{
$request = $this->getRequest();
if ($request->attributes->has(SecurityRequestAttributes::LAST_USERNAME)) {
return $request->attributes->get(SecurityRequestAttributes::LAST_USERNAME, '');
}
return $request->hasSession() ? $request->getSession()->get(SecurityRequestAttributes::LAST_USERNAME, '') : '';
}
Additional Context
No response