Merge branch 'main' of github.com:cerebrate-project/cerebrate into main
commit
1f57809029
|
@ -199,6 +199,9 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
'model_title' => __('Successful Keycloak enrollment for user {0}', $user['username']),
|
'model_title' => __('Successful Keycloak enrollment for user {0}', $user['username']),
|
||||||
'changed' => $logChange
|
'changed' => $logChange
|
||||||
]);
|
]);
|
||||||
|
$saved_user = $this->getCerebrateUsers($user['id']);
|
||||||
|
$clientId = $this->getClientId();
|
||||||
|
$this->syncUsers($saved_user, $clientId);
|
||||||
$response = $this->restApiRequest(
|
$response = $this->restApiRequest(
|
||||||
'%s/admin/realms/%s/users/' . urlencode($newUserId) . '/execute-actions-email',
|
'%s/admin/realms/%s/users/' . urlencode($newUserId) . '/execute-actions-email',
|
||||||
['UPDATE_PASSWORD'],
|
['UPDATE_PASSWORD'],
|
||||||
|
@ -357,10 +360,10 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
return $keycloakUsersParsed;
|
return $keycloakUsersParsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCerebrateUsers(): array
|
private function getCerebrateUsers($id = null): array
|
||||||
{
|
{
|
||||||
$metaFieldsSelector = ['fields' => ['MetaFields.field', 'MetaFields.parent_id', 'MetaFields.value']];
|
$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',
|
'id',
|
||||||
'uuid',
|
'uuid',
|
||||||
'username',
|
'username',
|
||||||
|
@ -373,7 +376,11 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
'Roles.uuid',
|
'Roles.uuid',
|
||||||
'Organisations.name',
|
'Organisations.name',
|
||||||
'Organisations.uuid'
|
'Organisations.uuid'
|
||||||
])->disableHydration()->toArray();
|
]);
|
||||||
|
if ($id) {
|
||||||
|
$query->where(['User.id' => $id]);
|
||||||
|
}
|
||||||
|
$results = $query->disableHydration()->toArray();
|
||||||
foreach ($results as &$result) {
|
foreach ($results as &$result) {
|
||||||
if (!empty($result['meta_fields'])) {
|
if (!empty($result['meta_fields'])) {
|
||||||
$temp = [];
|
$temp = [];
|
||||||
|
|
|
@ -80,13 +80,6 @@ class UsersTable extends AppTable
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterSave(EventInterface $event, EntityInterface $entity, ArrayObject $options)
|
|
||||||
{
|
|
||||||
if ($entity->isNew()) {
|
|
||||||
$this->handleUserUpdateRouter($entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function checkPermissionRestrictions(EntityInterface $entity)
|
private function checkPermissionRestrictions(EntityInterface $entity)
|
||||||
{
|
{
|
||||||
if (!isset($this->PermissionLimitations)) {
|
if (!isset($this->PermissionLimitations)) {
|
||||||
|
|
Loading…
Reference in New Issue