fix: [user enrollment] fixed via KC
parent
a88318c5df
commit
398307e414
|
@ -150,15 +150,12 @@ class AuthKeycloakBehavior extends Behavior
|
|||
foreach ($roles as $role) {
|
||||
$rolesParsed[$role['name']] = $role['id'];
|
||||
}
|
||||
$this->createUser($user, $clientId, $rolesParsed);
|
||||
$logChange = [
|
||||
'username' => $user['username'],
|
||||
'individual_id' => $user['individual']['id'],
|
||||
'role_id' => $user['role']['id']
|
||||
];
|
||||
if (!$response->isOk()) {
|
||||
$logChange['code'] = $response->getStatusCode();
|
||||
$logChange['error_body'] = $response->getStringBody();
|
||||
if ($this->createUser($user, $clientId, $rolesParsed)) {
|
||||
$logChange = [
|
||||
'username' => $user['username'],
|
||||
'individual_id' => $user['individual']['id'],
|
||||
'role_id' => $user['role']['id']
|
||||
];
|
||||
$this->_table->auditLogs()->insert([
|
||||
'request_action' => 'enrollUser',
|
||||
'model' => 'User',
|
||||
|
@ -167,6 +164,11 @@ class AuthKeycloakBehavior extends Behavior
|
|||
'changed' => $logChange
|
||||
]);
|
||||
} else {
|
||||
$logChange = [
|
||||
'username' => $user['username'],
|
||||
'individual_id' => $user['individual']['id'],
|
||||
'role_id' => $user['role']['id']
|
||||
];
|
||||
$this->_table->auditLogs()->insert([
|
||||
'request_action' => 'enrollUser',
|
||||
'model' => 'User',
|
||||
|
@ -406,10 +408,14 @@ class AuthKeycloakBehavior extends Behavior
|
|||
]);
|
||||
}
|
||||
$newUser = $this->restApiRequest('%s/admin/realms/%s/users?username=' . urlencode($user['username']), [], 'get');
|
||||
$user['id'] = json_decode($newUser->getStringBody(), true);
|
||||
if (empty($user['id'])) {
|
||||
$users = json_decode($newUser->getStringBody(), true);
|
||||
if (empty($users[0]['id'])) {
|
||||
return false;
|
||||
}
|
||||
if (is_array($users[0]['id'])) {
|
||||
$users[0]['id'] = $users[0]['id'][0];
|
||||
}
|
||||
$user['id'] = $users[0]['id'];
|
||||
$this->assignRolesToUser($user, $rolesParsed, $clientId);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue