Skip to content

Commit

Permalink
add: application no permissions check
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatank committed Apr 25, 2024
1 parent 6a15ec7 commit d5d371f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/admin-ui/src/component/applications/ApplicationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ function ApplicationDetails({
data,
loading: isLoading,
refetch,
error,
} = useQuery<Query, QueryApplicationArgs>(APPLICATION_ADMIN_QUERY, {
skip: applicationPk === 0,
variables: { id },
Expand All @@ -413,6 +414,17 @@ function ApplicationDetails({
return <Loader />;
}

if (error) {
return <div>{t("errors.errorFetchingApplication")}</div>;
}

// NOTE id query will return null if the application is not found or the user does not have permission
// we can't distinguish between these two cases
const canView = application != null;
if (!canView) {
return <div>{t("errors.noPermission")}</div>;
}

const isOrganisation = application?.organisation != null;

// TODO replace this with an explicit check and warn on undefined fields
Expand Down

0 comments on commit d5d371f

Please sign in to comment.