summaryrefslogtreecommitdiffstats
path: root/Guard/Authenticator/AbstractFormLoginAuthenticator.php
diff options
context:
space:
mode:
authorNicolas Grekas <nicolas.grekas@gmail.com>2016-07-01 18:00:00 +0200
committerNicolas Grekas <nicolas.grekas@gmail.com>2016-07-01 18:00:00 +0200
commit8a9f6c7452644aaa3ecf9dbf59fa0150fccc56c6 (patch)
tree84267ff60c7a4ef488aa8db5e9c496a8c9fac37d /Guard/Authenticator/AbstractFormLoginAuthenticator.php
parentee959deafc05bb80f579827bfea736082949911b (diff)
parent4e06cf1b8ced0204d2b569caac39ce92c6e11717 (diff)
downloadsymfony-security-8a9f6c7452644aaa3ecf9dbf59fa0150fccc56c6.zip
symfony-security-8a9f6c7452644aaa3ecf9dbf59fa0150fccc56c6.tar.gz
symfony-security-8a9f6c7452644aaa3ecf9dbf59fa0150fccc56c6.tar.bz2
Merge branch '3.0' into 3.1
* 3.0: [travis] Fix deps=low/high builds fixed CS skip test with current phpunit bridge Fix for #19183 to add support for new PHP MongoDB extension in sessions. [Console] Fix for block() padding formatting after #19189 [Security][Guard] check if session exist before using it bumped Symfony version to 3.0.9 updated VERSION for 3.0.8 updated CHANGELOG for 3.0.8 bumped Symfony version to 2.8.9 updated VERSION for 2.8.8 updated CHANGELOG for 2.8.8 bumped Symfony version to 2.7.16 updated VERSION for 2.7.15 update CONTRIBUTORS for 2.7.15 updated CHANGELOG for 2.7.15 Fix some lowest deps Fixed typos in the expectedException annotations Conflicts: src/Symfony/Component/HttpKernel/Kernel.php src/Symfony/Component/Security/Guard/Authenticator/AbstractFormLoginAuthenticator.php
Diffstat (limited to 'Guard/Authenticator/AbstractFormLoginAuthenticator.php')
-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();