fix: [users:view] Gracefully handle the case where user exist in cerebrate but not in keycloak
parent
8c94aae994
commit
0b052aaebf
|
@ -160,7 +160,7 @@ class UsersController extends AppController
|
||||||
'afterFind' => function($data) use ($keycloakUsersParsed) {
|
'afterFind' => function($data) use ($keycloakUsersParsed) {
|
||||||
$data = $this->fetchTable('PermissionLimitations')->attachLimitations($data);
|
$data = $this->fetchTable('PermissionLimitations')->attachLimitations($data);
|
||||||
if (!empty(Configure::read('keycloak.enabled'))) {
|
if (!empty(Configure::read('keycloak.enabled'))) {
|
||||||
$keycloakUser = $keycloakUsersParsed[$data->username];
|
$keycloakUser = $keycloakUsersParsed[$data->username] ?? [];
|
||||||
$data['keycloak_status'] = array_values($this->Users->checkKeycloakStatus([$data->toArray()], [$keycloakUser]))[0];
|
$data['keycloak_status'] = array_values($this->Users->checkKeycloakStatus([$data->toArray()], [$keycloakUser]))[0];
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
|
|
|
@ -405,7 +405,8 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
$status = [];
|
$status = [];
|
||||||
foreach ($users as $username => $user) {
|
foreach ($users as $username => $user) {
|
||||||
$differences = [];
|
$differences = [];
|
||||||
$requireUpdate = $this->checkKeycloakUserRequiresUpdate($keycloakUsersParsed[$username], $user, $differences);
|
$keycloakUser = $keycloakUsersParsed[$username] ?? [];
|
||||||
|
$requireUpdate = $this->checkKeycloakUserRequiresUpdate($keycloakUser, $user, $differences);
|
||||||
$status[$user['id']] = [
|
$status[$user['id']] = [
|
||||||
'require_update' => $requireUpdate,
|
'require_update' => $requireUpdate,
|
||||||
'differences' => $differences,
|
'differences' => $differences,
|
||||||
|
@ -416,7 +417,6 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
|
|
||||||
private function checkKeycloakUserRequiresUpdate(array $keycloakUser, array $user, array &$differences = []): bool
|
private function checkKeycloakUserRequiresUpdate(array $keycloakUser, array $user, array &$differences = []): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
$condEnabled = $keycloakUser['enabled'] == $user['disabled'];
|
$condEnabled = $keycloakUser['enabled'] == $user['disabled'];
|
||||||
$condFirstname = mb_strtolower($keycloakUser['firstName']) !== mb_strtolower($user['individual']['first_name']);
|
$condFirstname = mb_strtolower($keycloakUser['firstName']) !== mb_strtolower($user['individual']['first_name']);
|
||||||
$condLastname = mb_strtolower($keycloakUser['lastName']) !== mb_strtolower($user['individual']['last_name']);
|
$condLastname = mb_strtolower($keycloakUser['lastName']) !== mb_strtolower($user['individual']['last_name']);
|
||||||
|
|
Loading…
Reference in New Issue