whio-api-sdk 1.0.227-beta-staging → 1.0.228-beta-staging
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,11 +26,14 @@ export class UserModule extends BaseClient {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
assignRoleToUser(userId, roleName, organizationId) {
|
|
29
|
-
var _a;
|
|
29
|
+
var _a, _b;
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
const orgId = organizationId || ((_a = this.user) === null || _a === void 0 ? void 0 : _a.organizationId);
|
|
32
32
|
const organization = yield this.request(`${urls.organizations}/${orgId}`, 'GET');
|
|
33
|
-
const orgRoleEditor = organization.roles.find(r => r.name === roleName);
|
|
33
|
+
const orgRoleEditor = (_b = organization.roles) === null || _b === void 0 ? void 0 : _b.find(r => r.name === roleName);
|
|
34
|
+
if (!orgRoleEditor) {
|
|
35
|
+
throw new Error(`Role ${roleName} not found in organization ${orgId}`);
|
|
36
|
+
}
|
|
34
37
|
const assignRoleDto = {
|
|
35
38
|
userId: userId,
|
|
36
39
|
organizationRoleId: orgRoleEditor.id,
|
package/package.json
CHANGED
|
@@ -27,10 +27,13 @@ export class UserModule extends BaseClient {
|
|
|
27
27
|
`${urls.organizations}/${orgId}`,
|
|
28
28
|
'GET'
|
|
29
29
|
);
|
|
30
|
-
const orgRoleEditor = organization.roles
|
|
30
|
+
const orgRoleEditor = organization.roles?.find(r => r.name === roleName);
|
|
31
|
+
if (!orgRoleEditor) {
|
|
32
|
+
throw new Error(`Role ${roleName} not found in organization ${orgId}`);
|
|
33
|
+
}
|
|
31
34
|
const assignRoleDto: AssignOrganizationRoleDto = {
|
|
32
35
|
userId: userId,
|
|
33
|
-
organizationRoleId: orgRoleEditor
|
|
36
|
+
organizationRoleId: orgRoleEditor.id,
|
|
34
37
|
};
|
|
35
38
|
this.request(urls.userOrganizationRoles, 'POST', assignRoleDto);
|
|
36
39
|
const userWithOrgRole = await this.request<User>(`${urls.user}/${userId}`, 'GET');
|