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 May 13, 2024
1 parent b89a622 commit 0a4d3dd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/admin-ui/src/spa/applications/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ function ApplicationDetails({
data,
loading: isLoading,
refetch,
error,
} = useQuery<Query, QueryApplicationArgs>(APPLICATION_ADMIN_QUERY, {
skip: applicationPk === 0,
variables: { id },
Expand All @@ -839,6 +840,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 0a4d3dd

Please sign in to comment.