1000 search results

// ... lines 1 - 4
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\Security\FirewallConfig;
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
use Symfony\Bundle\SecurityBundle\Security\TargetPathHelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class TargetPathHelperTest extends TestCase
{
public function testSavePath()
{
$session = $this->createMock(SessionInterface::class);
$firewallMap = $this->createMock(FirewallMap::class);
$requestStack = $this->createMock(RequestStack::class);
$request = new Request();
$requestStack->expects($this->once())
->method('getMasterRequest')
->willReturn($request);
$firewallConfig = new FirewallConfig('firewall_name', '');
$firewallMap->expects($this->once())
->method('getFirewallConfig')
->with($request)
->willReturn($firewallConfig);
$session->expects($this->once())
->method('set')
->with('_security.firewall_name.target_path', '/foo');
$targetPathHelper = new TargetPathHelper($session, $firewallMap, $requestStack);
$targetPathHelper->savePath('/foo');
}
}
See Code Block in Script
// ... lines 1 - 4
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\Security\FirewallConfig;
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
use Symfony\Bundle\SecurityBundle\Security\TargetPathHelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
// ... lines 12 - 39
See Code Block in Script
414 lines | symfony-docs/security/form_login.rst
// ... lines 1 - 6
Using a :doc:`form login </security/form_login_setup>` for authentication is a
// ... lines 8 - 10
:doc:`form login configuration reference </reference/configuration/security>` to
// ... lines 12 - 414
See Code Block in Script
426 lines | symfony-docs/security/form_login.rst
// ... lines 1 - 392
The last request URI is stored in a session variable named
``_security.<your providerKey>.target_path`` (e.g. ``_security.main.target_path``
if the name of your firewall is ``main``). Most of the times you don't have to
deal with this low level session variable. However, if you ever need to get or
remove this variable, it's better to use the
:class:`Symfony\\Component\\Security\\Http\\Util\\TargetPathTrait` utility::
// ...
use Symfony\Component\Security\Http\Util\TargetPathTrait;
$targetPath = $this->getTargetPath($request->getSession(), $providerKey);
// equivalent to:
// $targetPath = $request->getSession()->get('_security.'.$providerKey.'.target_path');
You can also use the ``TargetPathHelper`` service in the same way::
// ... lines 409 - 426
See Code Block in Script
426 lines | symfony-docs/security/form_login.rst
// ... lines 1 - 407
You can also use the ``TargetPathHelper`` service in the same way::
// ... for example: from inside a controller
// ... line 411
// ...
public function register(Request $request, TargetPathHelper $targetPathHelper)
{
// the user clicked to register: save the previous URL
if ($request->isMethod('GET') && !$targetPathHelper->getPath()) {
// redirect to the Referer, or the homepage if none
$target = $request->headers->get('Referer', $this->generateUrl('homepage');
$targetPathHelper->savePath($target);
}
// later, after a successful registration POST submit
return $this->redirect($targetPathHelper->getPath());
}
See Code Block in Script
426 lines | symfony-docs/security/form_login.rst
// ... lines 1 - 407
You can also use the ``TargetPathHelper`` service in the same way::
// ... for example: from inside a controller
// ... lines 411 - 426
See Code Block in Script
426 lines | symfony-docs/security/form_login.rst
// ... lines 1 - 407
You can also use the ``TargetPathHelper`` service in the same way::
// ... for example: from inside a controller
use Symfony\Bundle\SecurityBundle\Security\TargetPathHelper;
// ...
// ... lines 413 - 426
See Code Block in Script
429 lines | symfony-docs/security/form_login.rst
// ... lines 1 - 407
.. versionadded:: 4.2
// ... lines 409 - 410
You can also use the ``TargetPathHelper`` service in the same way::
// ... lines 412 - 429
See Code Block in Script
429 lines | symfony-docs/security/form_login.rst
// ... lines 1 - 407
.. versionadded:: 4.2
The ``TargetPathHelper`` class was introduced in Symfony 4.2.
// ... lines 411 - 429
See Code Block in Script
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
// ... lines 6 - 12
<services>
// ... lines 14 - 162
<service id="security.target_path_helper" class="Symfony\Bundle\SecurityBundle\Security\TargetPathHelper">
// ... lines 164 - 166
</service>
// ... lines 168 - 223
</services>
</container>
See Code Block in Script
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
// ... lines 6 - 12
<services>
// ... lines 14 - 162
<service id="security.target_path_helper" class="Symfony\Bundle\SecurityBundle\Security\TargetPathHelper">
<argument type="service" id="session" />
<argument type="service" id="security.firewall.map" />
<argument type="service" id="request_stack" />
</service>
// ... lines 168 - 223
</services>
</container>
See Code Block in Script
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
// ... lines 6 - 12
<services>
// ... lines 14 - 167
<service id="Symfony\Bundle\SecurityBundle\Security\TargetPathHelper" alias="security.target_path_helper" />
// ... lines 169 - 223
</services>
</container>
See Code Block in Script
// ... lines 1 - 2
namespace Symfony\Bundle\SecurityBundle\Security;
class TargetPathHelper
{
public function savePath(string $uri)
{
}
}
See Code Block in Script
// ... lines 1 - 13
class TargetPathHelper
{
/**
* Sets the target path the user should be redirected to after authentication.
*
* @param string $uri The URI to set as the target path
*/
public function savePath(string $uri)
{
}
}
See Code Block in Script
// ... lines 1 - 13
class TargetPathHelper
{
/**
// ... lines 17 - 18
* @param string $uri The URI to set as the target path
*/
public function savePath(string $uri)
{
}
}
See Code Block in Script
// ... lines 1 - 2
/*
* 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\Bundle\SecurityBundle\Security;
class TargetPathHelper
{
// ... lines 16 - 24
}
See Code Block in Script
// ... lines 1 - 13
use Symfony\Component\Security\Http\Util\TargetPathTrait;
class TargetPathHelper
{
use TargetPathTrait;
// ... lines 19 - 28
}
See Code Block in Script
// ... lines 1 - 15
class TargetPathHelper
{
use TargetPathTrait;
// ... lines 19 - 24
public function savePath(string $uri)
{
$this->saveTargetPath();
}
}
See Code Block in Script
// ... lines 1 - 13
use Symfony\Component\HttpFoundation\Session\SessionInterface;
// ... lines 15 - 16
class TargetPathHelper
{
// ... lines 19 - 24
public function __construct(SessionInterface $session, FirewallMap $firewallMap)
{
// ... lines 27 - 28
}
// ... lines 30 - 44
}
See Code Block in Script
// ... lines 1 - 16
class TargetPathHelper
{
// ... lines 19 - 20
private $session;
private $firewallMap;
public function __construct(SessionInterface $session, FirewallMap $firewallMap)
{
$this->session = $session;
$this->firewallMap = $firewallMap;
}
// ... lines 30 - 44
}
See Code Block in Script