Skip to content

Commit

Permalink
Fix for not crashing when role not found
Browse files Browse the repository at this point in the history
  • Loading branch information
santosh898 committed Jul 2, 2024
1 parent 2435b03 commit 6a95209
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion js/apps/admin-ui/src/realm-roles/UsersInRoleTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export const UsersInRoleTab = () => {
const { adminClient } = useAdminClient();

const loader = async (first?: number, max?: number) => {
const role = await adminClient.roles.findOneById({ id: id });
const role = await adminClient.roles
.findOneById({ id: id })
.catch(() => undefined);
if (!role) {
throw new Error(t("common:notFound"));
}
Expand Down
8 changes: 5 additions & 3 deletions js/apps/admin-ui/src/user/EditUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ export default function EditUser() {
const isBruteForceProtected = currentRealm.bruteForceProtected;
const isLocked = isBruteForceProtected && attackDetection.disabled;

const serviceUsers = await adminClient.roles.findUsersWithRole({
name: "service",
});
const serviceUsers = await adminClient.roles
.findUsersWithRole({
name: "service",
})
.catch(() => [] as UserRepresentation[]);

return {
user,
Expand Down
8 changes: 5 additions & 3 deletions js/apps/admin-ui/src/user/UsersSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ export default function UsersSection() {
}

try {
const usersWithServiceRole = await adminClient.roles.findUsersWithRole({
name: "service",
});
const usersWithServiceRole = await adminClient.roles
.findUsersWithRole({
name: "service",
})
.catch(() => [] as UserRepresentation[]);

return (
await findUsers({
Expand Down

0 comments on commit 6a95209

Please sign in to comment.