Skip to content

Commit ac46df4

Browse files
committed
[#17328] Minor changes
1 parent 5611f88 commit ac46df4

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

security.rst

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ That's it! By sending a user to the ``app_logout`` route (i.e. to ``/logout``)
17241724
Symfony will un-authenticate the current user and redirect them.
17251725

17261726
Logout programmatically
1727-
-----------------------
1727+
~~~~~~~~~~~~~~~~~~~~~~~
17281728

17291729
.. versionadded:: 6.2
17301730

@@ -1737,35 +1737,31 @@ Logout programmatically
17371737
The :method:`Symfony\\Bundle\\SecurityBundle\\Security\\Security::logout`
17381738
method was introduced in Symfony 6.2.
17391739

1740-
You can logout user programmatically using the `logout()` method of the
1741-
:class:`Symfony\\Bundle\\SecurityBundle\\Security\\Security` helper. The user will be logout from the current firewall
1742-
in the request. If the current request is not behind a firewall a ``\LogicException`` will be thrown. ::
1740+
You can logout user programmatically using the ``logout()`` method of the
1741+
:class:`Symfony\\Bundle\\SecurityBundle\\Security\\Security` helper::
17431742

17441743
// src/Controller/SecurityController.php
17451744
namespace App\Controller\SecurityController;
17461745

1747-
use App\Security\Authenticator\ExampleAuthenticator;
17481746
use Symfony\Bundle\SecurityBundle\Security\Security;
17491747

17501748
class SecurityController
17511749
{
17521750
public function someAction(Security $security): Response
17531751
{
17541752
// logout the user in on the current firewall
1755-
$response = $this->security->logout();
1756-
1757-
// You can also disable the csrf logout
1758-
$response = $this->security->logout(false);
1753+
$response = $security->logout();
17591754

1760-
if ($response !== null) {
1761-
return $response;
1762-
}
1755+
// you can also disable the csrf logout
1756+
$response = $security->logout(false);
17631757

1764-
// Redirect to the homepage for instance
1765-
// ...
1758+
// ... return $response (if set) or e.g. redirect to the homepage
17661759
}
17671760
}
17681761

1762+
The user will be logout from the firewall of the request. If the request is
1763+
not behind a firewall a ``\LogicException`` will be thrown.
1764+
17691765
Customizing Logout
17701766
~~~~~~~~~~~~~~~~~~
17711767

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy