summaryrefslogtreecommitdiffstats
path: root/Guard/Authenticator
diff options
context:
space:
mode:
Diffstat (limited to 'Guard/Authenticator')
-rw-r--r--Guard/Authenticator/AbstractFormLoginAuthenticator.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/Guard/Authenticator/AbstractFormLoginAuthenticator.php b/Guard/Authenticator/AbstractFormLoginAuthenticator.php
index d10e486..f99900b 100644
--- a/Guard/Authenticator/AbstractFormLoginAuthenticator.php
+++ b/Guard/Authenticator/AbstractFormLoginAuthenticator.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Guard\Authenticator;
+use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -45,7 +46,10 @@ abstract class AbstractFormLoginAuthenticator extends AbstractGuardAuthenticator
*/
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
- $request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception);
+ if ($request->getSession() instanceof SessionInterface) {
+ $request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception);
+ }
+
$url = $this->getLoginUrl();
return new RedirectResponse($url);
@@ -65,12 +69,16 @@ abstract class AbstractFormLoginAuthenticator extends AbstractGuardAuthenticator
@trigger_error(sprintf('The AbstractFormLoginAuthenticator::onAuthenticationSuccess() implementation was deprecated in Symfony 3.1 and will be removed in Symfony 4.0. You should implement this method yourself in %s and remove getDefaultSuccessRedirectUrl().', get_class($this)), E_USER_DEPRECATED);
if (!method_exists($this, 'getDefaultSuccessRedirectUrl')) {
- throw new \Exception(sprintf('You must implement onAuthenticationSuccess() or getDefaultSuccessRedirectURL() in %s.', get_class($this)));
+ throw new \Exception(sprintf('You must implement onAuthenticationSuccess() or getDefaultSuccessRedirectUrl() in %s.', get_class($this)));
}
- // if the user hits a secure page and start() was called, this was
+ $targetPath = null;
+
+ // if the user hit a secure page and start() was called, this was
// the URL they were on, and probably where you want to redirect to
- $targetPath = $this->getTargetPath($request->getSession(), $providerKey);
+ if ($request->getSession() instanceof SessionInterface) {
+ $targetPath = $this->getTargetPath($request->getSession(), $providerKey);
+ }
if (!$targetPath) {
$targetPath = $this->getDefaultSuccessRedirectUrl();