Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener::handle PHP 메소드

handle() 최종 공개 메소드

Handles form based authentication.
final public handle ( GetResponseEvent $event )
$event Symfony\Component\HttpKernel\Event\GetResponseEvent A GetResponseEvent instance
    public final function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        if (!$this->requiresAuthentication($request)) {
            return;
        }

        try {
            if (null === $returnValue = $this->attemptAuthentication($request)) {
                return;
            }

            if (!$request->hasSession()) {
                throw new \RuntimeException('This authentication method requires a session.');
            }

            if (!$request->hasPreviousSession()) {
                throw new SessionUnavailableException('Your session has timed-out, or you have disabled cookies.');
            }

            if ($returnValue instanceof TokenInterface) {
                $this->sessionStrategy->onAuthentication($request, $returnValue);

                $response = $this->onSuccess($event, $request, $returnValue);
            } else if ($returnValue instanceof Response) {
                $response = $returnValue;
            } else {
                throw new \RuntimeException('attemptAuthentication() must either return a Response, an implementation of TokenInterface, or null.');
            }
        } catch (AuthenticationException $e) {
            $response = $this->onFailure($event, $request, $e);
        }

        $event->setResponse($response);
    }