Skip to content

Commit

Permalink
Merge pull request #1576 from ConductionNL/fix/beheer-358/also-accept…
Browse files Browse the repository at this point in the history
…-group

Also accept group as field for groups
  • Loading branch information
rjzondervan authored Oct 24, 2023
2 parents 0de5dd8 + bfc72e1 commit 6bd64b4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions api/src/Security/OIDCAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public function authenticate(Request $request): PassportInterface
$result['groups'] = [$result['groups']];
} else if (isset($result['groups']) === false || is_array($result['groups']) === false) {
$result['groups'] = [];
if (isset($result['group']) === true && is_array($result['group']) === true) {
$result['groups'] = $result['group'];
}
}

// Set default organization in session for multitenancy (see how this is done in other Authenticators, this can be different for each one!)
Expand All @@ -117,10 +120,10 @@ public function authenticate(Request $request): PassportInterface
$this->session->set('organizations', $organizations);
$this->session->set('parentOrganizations', $parentOrganizations);
$this->session->set('activeOrganization', $defaultOrganization);
if (isset($accessToken['refresh_token'])) {
$this->session->set('refresh_token', $accessToken['refresh_token']);
$userIdentifier = $result['email'];
} else {
// if (isset($accessToken['refresh_token'])) {
// $this->session->set('refresh_token', $accessToken['refresh_token']);
// $userIdentifier = $result['email'];
// } else {
$doctrineUser = $this->entityManager->getRepository('App:User')->findOneBy(['email' => $result['email']]);
if($doctrineUser instanceof User === false) {
$doctrineUser = new User();
Expand Down Expand Up @@ -150,7 +153,7 @@ public function authenticate(Request $request): PassportInterface

$this->entityManager->persist($doctrineUser);
$this->entityManager->flush();
}
// }

return new Passport(
new UserBadge($userIdentifier, function ($userIdentifier) use ($result) {
Expand Down

0 comments on commit 6bd64b4

Please sign in to comment.