Closed
Description
Sometimes $request maybe with empty session: [session:protected] =>
$targetPath = $this->getTargetPath($request->getSession(), $providerKey);
if (!$targetPath) {
$targetPath = $this->getDefaultSuccessRedirectUrl();
}
I had Catchable fatal error: Argument 1 passed to Symfony\\Component\\Security\\Guard\\Authenticator\\AbstractFormLoginAuthenticator::getTargetPath() must be an instance of Symfony\\Component\\HttpFoundation\\Session\\SessionInterface, null given
Maybe better to do something like below
$session = $request->getSession();
if ($session instanceof SessionInterface) {
$targetPath = $this->getTargetPath($session, $providerKey);
}
if (!isset($targetPath) || !$targetPath) {
$targetPath = $this->getDefaultSuccessRedirectUrl();
}