Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cerebrate-project/cerebrate into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mokaddem committed Apr 9, 2024
2 parents 2c8c967 + b2eb86d commit 1f57809
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
13 changes: 10 additions & 3 deletions src/Model/Behavior/AuthKeycloakBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ public function enrollUser($data): bool
'model_title' => __('Successful Keycloak enrollment for user {0}', $user['username']),
'changed' => $logChange
]);
$saved_user = $this->getCerebrateUsers($user['id']);
$clientId = $this->getClientId();
$this->syncUsers($saved_user, $clientId);
$response = $this->restApiRequest(
'%s/admin/realms/%s/users/' . urlencode($newUserId) . '/execute-actions-email',
['UPDATE_PASSWORD'],
Expand Down Expand Up @@ -357,10 +360,10 @@ public function getParsedKeycloakUser(): array
return $keycloakUsersParsed;
}

private function getCerebrateUsers(): array
private function getCerebrateUsers($id = null): array
{
$metaFieldsSelector = ['fields' => ['MetaFields.field', 'MetaFields.parent_id', 'MetaFields.value']];
$results = $this->_table->find()->contain(['Individuals', 'Organisations', 'Roles', 'MetaFields' => $metaFieldsSelector])->select([
$query = $this->_table->find()->contain(['Individuals', 'Organisations', 'Roles', 'MetaFields' => $metaFieldsSelector])->select([
'id',
'uuid',
'username',
Expand All @@ -373,7 +376,11 @@ private function getCerebrateUsers(): array
'Roles.uuid',
'Organisations.name',
'Organisations.uuid'
])->disableHydration()->toArray();
]);
if ($id) {
$query->where(['User.id' => $id]);
}
$results = $query->disableHydration()->toArray();
foreach ($results as &$result) {
if (!empty($result['meta_fields'])) {
$temp = [];
Expand Down
7 changes: 0 additions & 7 deletions src/Model/Table/UsersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ public function beforeSave(EventInterface $event, EntityInterface $entity, Array
return $success;
}

public function afterSave(EventInterface $event, EntityInterface $entity, ArrayObject $options)
{
if ($entity->isNew()) {
$this->handleUserUpdateRouter($entity);
}
}

private function checkPermissionRestrictions(EntityInterface $entity)
{
if (!isset($this->PermissionLimitations)) {
Expand Down

0 comments on commit 1f57809

Please sign in to comment.