summaryrefslogtreecommitdiffstats
path: root/Http/Authentication
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2016-03-02 13:34:29 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2016-03-02 13:34:29 +0100
commit44bb78fa355b490dd7163df472c861280eca8c5c (patch)
treede50af0de8ae3797e0c72910fb25c17540b9fafc /Http/Authentication
parentf416b655ca311f84e32a4ac05be0da1e83763734 (diff)
parent0d6c99afcc9f9392a4eea87caa9b197f176d54b7 (diff)
downloadsymfony-security-44bb78fa355b490dd7163df472c861280eca8c5c.zip
symfony-security-44bb78fa355b490dd7163df472c861280eca8c5c.tar.gz
symfony-security-44bb78fa355b490dd7163df472c861280eca8c5c.tar.bz2
feature #17714 Adding new TargetPathTrait to get/set the authentication "target_path" (weaverryan)
This PR was squashed before being merged into the 3.1-dev branch (closes #17714). Discussion ---------- Adding new TargetPathTrait to get/set the authentication "target_path" | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | not yet... Hi guys! This is a small guy. Basically, when you're doing custom auth (i.e. a guard authenticator), it's common to need the previous URL the user tried to get to (i.e. the "target path"). It's not much work to do it now, but it's very abstract - needing to know a weird string pattern. This just wraps that weirdness up in a simple function (`getTargetPath()`). Thanks! Commits ------- 18dfe37 Adding new TargetPathTrait to get/set the authentication "target_path"
Diffstat (limited to 'Http/Authentication')
-rw-r--r--Http/Authentication/DefaultAuthenticationSuccessHandler.php7
1 files changed, 5 insertions, 2 deletions
diff --git a/Http/Authentication/DefaultAuthenticationSuccessHandler.php b/Http/Authentication/DefaultAuthenticationSuccessHandler.php
index 078a366..38690c7 100644
--- a/Http/Authentication/DefaultAuthenticationSuccessHandler.php
+++ b/Http/Authentication/DefaultAuthenticationSuccessHandler.php
@@ -13,6 +13,7 @@ namespace Symfony\Component\Security\Http\Authentication;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Security\Http\Util\TargetPathTrait;
use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Component\Security\Http\ParameterBagUtils;
@@ -25,6 +26,8 @@ use Symfony\Component\Security\Http\ParameterBagUtils;
*/
class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
{
+ use TargetPathTrait;
+
protected $httpUtils;
protected $options;
protected $providerKey;
@@ -113,8 +116,8 @@ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandle
return $targetUrl;
}
- if (null !== $this->providerKey && $targetUrl = $request->getSession()->get('_security.'.$this->providerKey.'.target_path')) {
- $request->getSession()->remove('_security.'.$this->providerKey.'.target_path');
+ if (null !== $this->providerKey && $targetUrl = $this->getTargetPath($request->getSession(), $this->providerKey)) {
+ $this->removeTargetPath($request->getSession(), $this->providerKey);
return $targetUrl;
}