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

Skip to content

Commit 7061bfb

Browse files
committed
show unique inherited roles
1 parent 20485d1 commit 7061bfb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function collect(Request $request, Response $response, \Exception $except
8282
'token_class' => get_class($token),
8383
'user' => $token->getUsername(),
8484
'roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $assignedRoles),
85-
'inherited_roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $inheritedRoles),
85+
'inherited_roles' => array_unique(array_map(function (RoleInterface $role) { return $role->getRole(); }, $inheritedRoles)),
8686
'supports_role_hierarchy' => null !== $this->roleHierarchy,
8787
);
8888
}

src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,19 @@ public function provideRoles()
111111
array('ROLE_ADMIN'),
112112
array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
113113
),
114+
array(
115+
array('ROLE_ADMIN', 'ROLE_OPERATOR'),
116+
array('ROLE_ADMIN', 'ROLE_OPERATOR'),
117+
array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
118+
),
114119
);
115120
}
116121

117122
private function getRoleHierarchy()
118123
{
119124
return new RoleHierarchy(array(
120125
'ROLE_ADMIN' => array('ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'),
126+
'ROLE_OPERATOR' => array('ROLE_USER'),
121127
));
122128
}
123129

0 commit comments

Comments
 (0)