/
var
/
www
/
html
/
amply
/
vendor
/
symfony
/
security-http
/
Authenticator
/
Upload File
HOME
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http\Authenticator; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; /** * A base class to make form login authentication easier! * * @author Ryan Weaver <ryan@symfonycasts.com> * * @experimental in 5.1 */ abstract class AbstractLoginFormAuthenticator extends AbstractAuthenticator implements AuthenticationEntryPointInterface, InteractiveAuthenticatorInterface { /** * Return the URL to the login page. */ abstract protected function getLoginUrl(Request $request): string; /** * Override to change what happens after a bad username/password is submitted. */ public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response { if ($request->hasSession()) { $request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception); } $url = $this->getLoginUrl($request); return new RedirectResponse($url); } /** * Override to control what happens when the user hits a secure page * but isn't logged in yet. */ public function start(Request $request, AuthenticationException $authException = null): Response { $url = $this->getLoginUrl($request); return new RedirectResponse($url); } public function isInteractive(): bool { return true; } }