8000 Empty session in AbstractFormLoginAuthenticator of Guard · Issue #18958 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Empty session in AbstractFormLoginAuthenticator of Guard #18958
Closed
@Shekhovtsovy

Description

@Shekhovtsovy

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();
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0