AdmissionLoader: Set additional user information `assigned_roles`

This commit is contained in:
Johannes Meyer 2021-03-22 15:21:36 +01:00
parent 8ff88cd6f1
commit 9d10424f97
1 changed files with 9 additions and 1 deletions

View File

@ -179,9 +179,15 @@ class AdmissionLoader
$roles = [];
$permissions = [];
$restrictions = [];
$assignedRoles = [];
$isUnrestricted = false;
foreach ($this->roleConfig as $roleName => $roleConfig) {
if (! isset($roles[$roleName]) && $this->match($username, $userGroups, $roleConfig)) {
$assigned = $this->match($username, $userGroups, $roleConfig);
if ($assigned) {
$assignedRoles[] = $roleName;
}
if (! isset($roles[$roleName]) && $assigned) {
foreach ($this->loadRole($roleName, $roleConfig) as $role) {
/** @var Role $role */
$roles[$role->getName()] = $role;
@ -206,6 +212,8 @@ class AdmissionLoader
}
}
$user->setAdditional('assigned_roles', $assignedRoles);
$user->setIsUnrestricted($isUnrestricted);
$user->setRestrictions($isUnrestricted ? [] : $restrictions);
$user->setPermissions($permissions);