fix: [keycloak] when enrolling users in keycloak, use the user organisation_id instead of the individual's first alias
parent
3cc857c42f
commit
92fee87a7f
|
@ -98,7 +98,7 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
{
|
{
|
||||||
$individual = $this->_table->Individuals->find()->where(
|
$individual = $this->_table->Individuals->find()->where(
|
||||||
['id' => $data['individual_id']]
|
['id' => $data['individual_id']]
|
||||||
)->contain(['Organisations'])->first();
|
)->first();
|
||||||
$roleConditions = [
|
$roleConditions = [
|
||||||
'id' => $data['role_id']
|
'id' => $data['role_id']
|
||||||
];
|
];
|
||||||
|
@ -106,10 +106,9 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
$roleConditions['name'] = Configure::read('keycloak.default_role_name');
|
$roleConditions['name'] = Configure::read('keycloak.default_role_name');
|
||||||
}
|
}
|
||||||
$role = $this->_table->Roles->find()->where($roleConditions)->first();
|
$role = $this->_table->Roles->find()->where($roleConditions)->first();
|
||||||
$orgs = [];
|
$org = $this->_table->Organisations->find()->where([
|
||||||
foreach ($individual['organisations'] as $org) {
|
['id' => $data['organisation_id']]
|
||||||
$orgs[] = $org['uuid'];
|
]);
|
||||||
}
|
|
||||||
$token = $this->getAdminAccessToken();
|
$token = $this->getAdminAccessToken();
|
||||||
$keyCloakUser = [
|
$keyCloakUser = [
|
||||||
'firstName' => $individual['first_name'],
|
'firstName' => $individual['first_name'],
|
||||||
|
@ -118,7 +117,7 @@ class AuthKeycloakBehavior extends Behavior
|
||||||
'email' => $individual['email'],
|
'email' => $individual['email'],
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'role_name' => empty($role['name']) ? Configure::read('keycloak.default_role_name') : $role['name'],
|
'role_name' => empty($role['name']) ? Configure::read('keycloak.default_role_name') : $role['name'],
|
||||||
'org_uuid' => empty($orgs[0]) ? '' : $orgs[0]
|
'org_uuid' => $orgs['uuid']
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$keycloakConfig = Configure::read('keycloak');
|
$keycloakConfig = Configure::read('keycloak');
|
||||||
|
|
Loading…
Reference in New Issue