Skip to content

Commit 6c3aae9

Browse files
committed
minor #18700 [Security] Show you can pass badges to Security::login (MatTheCat)
This PR was merged into the 6.4 branch. Discussion ---------- [Security] Show you can pass badges to `Security::login` Documents symfony/symfony#50939 and fixes #18697 Commits ------- bfa29bb [Security] Show you can pass badges to `Security::login`
2 parents 328e872 + bfa29bb commit 6c3aae9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

security.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,7 @@ You can log in a user programmatically using the ``login()`` method of the
17101710

17111711
use App\Security\Authenticator\ExampleAuthenticator;
17121712
use Symfony\Bundle\SecurityBundle\Security;
1713+
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\RememberMeBadge;
17131714

17141715
class SecurityController
17151716
{
@@ -1727,9 +1728,12 @@ You can log in a user programmatically using the ``login()`` method of the
17271728
// ...or the service id of custom authenticators
17281729
$security->login($user, ExampleAuthenticator::class);
17291730

1730-
// you can also log in on a different firewall
1731+
// you can also log in on a different firewall...
17311732
$security->login($user, 'form_login', 'other_firewall');
17321733

1734+
// ...and add badges
1735+
$security->login($user, 'form_login', 'other_firewall', [(new RememberMeBadge())->enable()]);
1736+
17331737
// use the redirection logic applied to regular login
17341738
$redirectResponse = $security->login($user);
17351739
return $redirectResponse;
@@ -1743,6 +1747,10 @@ You can log in a user programmatically using the ``login()`` method of the
17431747

17441748
The feature to use a custom redirection logic was introduced in Symfony 6.3.
17451749

1750+
.. versionadded:: 6.4
1751+
1752+
The feature to add badges was introduced in Symfony 6.4.
1753+
17461754
.. _security-logging-out:
17471755

17481756
Logging Out

0 commit comments

Comments
 (0)