Fix Generali
This commit is contained in:
@@ -79,9 +79,18 @@ export async function addMemberToOrganization(orgId: string, userId: string): Pr
|
||||
// Verificato contro un'istanza Keycloak 26.7 reale: l'endpoint richiede
|
||||
// Content-Type application/json con il solo id utente come stringa JSON nel
|
||||
// body (non un oggetto, e non text/plain: entrambi rispondono 415).
|
||||
await keycloakAdminHttp.post(`/organizations/${orgId}/members`, JSON.stringify(userId), {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
try {
|
||||
await keycloakAdminHttp.post(`/organizations/${orgId}/members`, JSON.stringify(userId), {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
} catch (err) {
|
||||
// Idempotente: un retry dopo un fallimento parziale (es. l'assegnazione
|
||||
// del ruolo realm successiva fallita) non deve rompersi solo perché
|
||||
// l'utente era già stato aggiunto all'org nel tentativo precedente.
|
||||
if (!axios.isAxiosError(err) || err.response?.status !== 409) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface OrganizationMember {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { assignUserToGroup, assignRealmRoleToUser } from '../keycloak-admin';
|
||||
import { assignRealmRoleToUser } from '../keycloak-admin';
|
||||
|
||||
// "ruolo" è usato qui anche come identificativo del gruppo Keycloak, in
|
||||
// attesa che createOrganizationGroup persista una mappa ruolo -> groupId
|
||||
// reale da risolvere in questo punto (vedi gruppi.service.ts).
|
||||
// "ruolo" qui è sempre un ruolo realm (capo-gruppo/capo-unita/capo/censito/...),
|
||||
// non un gruppo Keycloak: il gruppo interno all'organizzazione (Capi/Aiuto
|
||||
// capi/Censiti, creato da createOrganizationGroup) è un concetto distinto,
|
||||
// oggi non collegato a nessun input utente, e va assegnato a parte quando
|
||||
// servirà davvero.
|
||||
export async function assegnaGruppoERuolo(userId: string, ruolo: string): Promise<void> {
|
||||
await assignUserToGroup(userId, ruolo);
|
||||
await assignRealmRoleToUser(userId, ruolo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user