chg: [behavior:keycloak] Gracefully handle issues while syncing with keycloak
parent
178a5b658f
commit
d293cb52f8
|
@ -297,14 +297,26 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
'modified' => [],
|
'modified' => [],
|
||||||
];
|
];
|
||||||
foreach ($users as &$user) {
|
foreach ($users as &$user) {
|
||||||
if (empty($keycloakUsersParsed[$user['username']])) {
|
try {
|
||||||
if ($this->createUser($user, $clientId)) {
|
if (empty($keycloakUsersParsed[$user['username']])) {
|
||||||
$changes['created'][] = $user['username'];
|
if ($this->createUser($user, $clientId)) {
|
||||||
}
|
$changes['created'][] = $user['username'];
|
||||||
} else {
|
}
|
||||||
if ($this->checkAndUpdateUser($keycloakUsersParsed[$user['username']], $user)) {
|
} else {
|
||||||
$changes['modified'][] = $user['username'];
|
if ($this->checkAndUpdateUser($keycloakUsersParsed[$user['username']], $user)) {
|
||||||
|
$changes['modified'][] = $user['username'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->_table->auditLogs()->insert([
|
||||||
|
'request_action' => 'syncUsers',
|
||||||
|
'model' => 'User',
|
||||||
|
'model_id' => 0,
|
||||||
|
'model_title' => __('Failed to create or modify user ({0}) in keycloak', $user['username']),
|
||||||
|
'changed' => [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $changes;
|
return $changes;
|
||||||
|
|
Loading…
Reference in New Issue