Skip to content

Commit

Permalink
Merge pull request #516 from jannisko/patch-2
Browse files Browse the repository at this point in the history
also return user group array from the /userinfo endpoint
  • Loading branch information
H2CK authored Jan 23, 2025
2 parents bc9e391 + c6b7b45 commit 4c695ea
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lib/Controller/UserInfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,28 @@ public function getInfo(): JSONResponse

];

// Check for scopes
$scopeArray = preg_split('/ +/', $accessToken->getScope());

$roles = [];
foreach ($groups as $group) {
array_push($roles, $group->getGID());
}
$rolesPayload = [
'roles' => $roles
];
$userInfoPayload = array_merge($userInfoPayload, $rolesPayload);

// Check for scopes
$scopeArray = preg_split('/ +/', $accessToken->getScope());
if (in_array("roles", $scopeArray)) {
$rolesPayload = [
'roles' => $roles
];
$userInfoPayload = array_merge($userInfoPayload, $rolesPayload);
}

if (in_array("groups", $scopeArray)) {
$groupsPayload = [
'groups' => $roles
];
$userInfoPayload = array_merge($userInfoPayload, $groupsPayload);
}

if (in_array("profile", $scopeArray)) {
$profile = [
'updated_at' => $user->getLastLogin(),
Expand Down

0 comments on commit 4c695ea

Please sign in to comment.