Skip to content

Commit

Permalink
fix(ACL): ui should display an error when user has no permission to s…
Browse files Browse the repository at this point in the history
…et acl [#938]
  • Loading branch information
vitshev committed Feb 3, 2025
1 parent 2edc61b commit 93722c7
Showing 1 changed file with 33 additions and 34 deletions.
67 changes: 33 additions & 34 deletions packages/ui/src/ui/store/actions/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,44 +287,43 @@ export function requestPermissions(
const poolTree =
idmKind === IdmObjectType.POOL ? normalizedPoolTree || getTree(state) : undefined;

try {
const requestPermissionsPath = await getPathToCheckPermissions(
idmKind,
values.path,
poolTree,
);
const requestPermissionsPath = await getPathToCheckPermissions(
idmKind,
values.path,
poolTree,
);

//cluster, path, roles, comment, columns
return UIFactory.getAclApi()
.requestPermissions({
cluster,
path: values.path,
sysPath: requestPermissionsPath,
roles,
roles_grouped: rolesGroupedBySubject.map(convertFromUIPermissions),
comment: values.comment ?? '',
kind: idmKind,
poolTree,
})
.then(() => {
dispatch({
type: REQUEST_PERMISSION.SUCCESS,
idmKind,
});
});
} catch (error: any) {
if (isCancelled(error)) {
dispatch({type: REQUEST_PERMISSION.CANCELLED, idmKind});
return undefined;
} else {
//cluster, path, roles, comment, columns
return UIFactory.getAclApi()
.requestPermissions({
cluster,
path: values.path,
sysPath: requestPermissionsPath,
roles,
roles_grouped: rolesGroupedBySubject.map(convertFromUIPermissions),
comment: values.comment ?? '',
kind: idmKind,
poolTree,
})
.then(() => {
dispatch({
type: REQUEST_PERMISSION.FAILURE,
data: error,
type: REQUEST_PERMISSION.SUCCESS,
idmKind,
});
return Promise.reject(error);
}
}
})
.catch((error: any) => {
if (isCancelled(error)) {
dispatch({type: REQUEST_PERMISSION.CANCELLED, idmKind});
return undefined;
} else {
dispatch({
type: REQUEST_PERMISSION.FAILURE,
data: error,
idmKind,
});
return Promise.reject(error);
}
});
};
}

Expand Down

0 comments on commit 93722c7

Please sign in to comment.