8000 Fix recommendations from community review · symfony/symfony-docs@e6c569b · GitHub
[go: up one dir, main page]

Skip to content

Commit e6c569b

Browse files
jwmickeyjaviereguiluz
authored andcommitted
Fix recommendations from community review
1 parent cf3bd00 commit e6c569b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

security/impersonating_user.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ elevated user such as an administrator.
195195

196196
First, create the voter class::
197197

198-
namespace AppBundle\Security\Voter;
198+
namespace App\Security\Voter;
199199

200200
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
201201
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
@@ -227,7 +227,7 @@ First, create the voter class::
227227

228228
if (in_array('ROLE_CUSTOMER', $subject->getRoles())
229229
&& $this->hasSwitchToCustomerRole($token)) {
230-
return self::ACCESS_GRANTED;
230+
return true;
231231
}
232232

233233
return false;
@@ -340,6 +340,7 @@ the voter as a service:
340340
// config/services.php
341341
use App\Security\Voter\SwitchToCustomerVoter;
342342
use Symfony\Component\DependencyInjection\Definition;
343+
use Symfony\Component\DependencyInjection\Reference;
343344
344345
// Same as before
345346
$definition = new Definition();
@@ -354,7 +355,7 @@ the voter as a service:
354355
355356
// Explicitly configure the service
356357
$container->getDefinition(SwitchToCustomerVoter::class)
357-
->setArgument('$roleHierarchy', '@security.role_hierarchy');
358+
->setArgument('$roleHierarchy', new Reference('security.role_hierarchy'));
358359
359360
Now a user who has the ``ROLE_SWITCH_TO_CUSTOMER`` role can switch to a user who explicitly has the
360361
``ROLE_CUSTOMER`` role, but not other users.

0 commit comments

Comments
 (0)
0