Skip to content

Commit 136c4c0

Browse files
committed
Merge branch '5.0'
* 5.0: Fix test login example for 4.4 - 5.0 applications
2 parents 41232a8 + 58c189b commit 136c4c0

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
@@ -128,14 +128,17 @@ needs::
128128
{
129129
$session = self::$container->get('session');
130130

131+
// somehow fetch the user (e.g. using the user repository)
132+
$user = ...;
133+
131134
$firewallName = 'secure_area';
132135
// if you don't define multiple connected firewalls, the context defaults to the firewall name
133136
// See https://symfony.com/doc/current/reference/configuration/security.html#firewall-context
134137
$firewallContext = 'secured_area';
135138

136139
// you may need to use a different token class depending on your application.
137140
// for example, when using Guard authentication you must instantiate PostAuthenticationGuardToken
138-
$token = new UsernamePasswordToken('admin', null, $firewallName, ['ROLE_ADMIN']);
141+
$token = new UsernamePasswordToken($user, null, $firewallName, $user->getRoles());
139142
$session->set('_security_'.$firewallContext, serialize($token));
140143
$session->save();
141144

0 commit comments

Comments
 (0)