Compare commits
8 Commits
d4eaeed045
...
1f57809029
Author | SHA1 | Date |
---|---|---|
Sami Mokaddem | 1f57809029 | |
Sami Mokaddem | 2c8c967c06 | |
iglocska | b2eb86d659 | |
iglocska | 4657feaf6e | |
Sami Mokaddem | e9a79c54fc | |
Sami Mokaddem | c958f24190 | |
iglocska | 91be9ddeda | |
iglocska | 63d1ec76eb |
|
@ -94,6 +94,10 @@ if (file_exists(CONFIG . 'app_local.php')) {
|
||||||
$settings = file_get_contents(CONFIG . 'config.json');
|
$settings = file_get_contents(CONFIG . 'config.json');
|
||||||
$settings = json_decode($settings, true);
|
$settings = json_decode($settings, true);
|
||||||
foreach ($settings as $path => $setting) {
|
foreach ($settings as $path => $setting) {
|
||||||
|
if($path == 'debug') {
|
||||||
|
Configure::write($path, (bool) $setting);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Configure::write($path, $setting);
|
Configure::write($path, $setting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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'],
|
||||||
|
@ -335,7 +338,7 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
|
|
||||||
public function getParsedKeycloakUser(): array
|
public function getParsedKeycloakUser(): array
|
||||||
{
|
{
|
||||||
$response = $this->restApiRequest('%s/admin/realms/%s/users', [], 'get');
|
$response = $this->restApiRequest('%s/admin/realms/%s/users/?max=999999', [], 'get');
|
||||||
$keycloakUsers = json_decode($response->getStringBody(), true);
|
$keycloakUsers = json_decode($response->getStringBody(), true);
|
||||||
$keycloakUsersParsed = [];
|
$keycloakUsersParsed = [];
|
||||||
$mappers = array_merge(['role_name', 'role_uuid', 'org_uuid', 'org_name'], $this->getMappedFieldList());
|
$mappers = array_merge(['role_name', 'role_uuid', 'org_uuid', 'org_name'], $this->getMappedFieldList());
|
||||||
|
@ -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 = [];
|
||||||
|
|
|
@ -316,9 +316,8 @@ class CerebrateSettingsProvider extends BaseSettingsProvider
|
||||||
'description' => __('The debug level of the instance'),
|
'description' => __('The debug level of the instance'),
|
||||||
'default' => 0,
|
'default' => 0,
|
||||||
'options' => [
|
'options' => [
|
||||||
0 => __('Debug Off'),
|
false => __('Debug Off'),
|
||||||
1 => __('Debug On'),
|
true => __('Debug On'),
|
||||||
2 => __('Debug On + SQL Dump'),
|
|
||||||
],
|
],
|
||||||
'test' => function ($value, $setting, $validator) {
|
'test' => function ($value, $setting, $validator) {
|
||||||
$validator->range('value', [0, 2]);
|
$validator->range('value', [0, 2]);
|
||||||
|
|
Loading…
Reference in New Issue