Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 58c189b

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Fix test login example for 4.4 - 5.0 applications
2 parents de3dfb2 + bff0769 commit 58c189b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

testing/http_authentication.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,17 @@ needs::
113113
{
114114
$session = self::$container->get('session');
115115

116+
// somehow fetch the user (e.g. using the user repository)
117+
$user = ...;
118+
116119
$firewallName = 'secure_area';
117120
// if you don't define multiple connected firewalls, the context defaults to the firewall name
118121
// See https://symfony.com/doc/current/reference/configuration/security.html#firewall-context
119122
$firewallContext = 'secured_area';
120123

121124
// you may need to use a different token class depending on your application.
122125
// for example, when using Guard authentication you must instantiate PostAuthenticationGuardToken
123-
$token = new UsernamePasswordToken('admin', null, $firewallName, ['ROLE_ADMIN']);
126+
$token = new UsernamePasswordToken($user, null, $firewallName, $user->getRoles());
124127
$session->set('_security_'.$firewallContext, serialize($token));
125128
$session->save();
126129

0 commit comments

Comments
 (0)