Skip to content

Commit

Permalink
use role to help determine whether to show viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
gestchild committed Oct 7, 2024
1 parent a470c87 commit 1b5cfab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion content/webapp/pages/works/[workId]/items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const ItemPage: NextPage<Props> = ({
};

const needsModal = checkModalRequired({
role,
auth,
isAnyImageOpen,
authV2,
Expand Down Expand Up @@ -230,7 +231,7 @@ const ItemPage: NextPage<Props> = ({
setShowModal(false);
setShowViewer(true);
}
}, []);
}, [needsModal]);

return (
<CataloguePageLayout
Expand Down
9 changes: 7 additions & 2 deletions content/webapp/utils/iiif/v3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,14 @@ export function getTokenService(
}

type checkModalParams = {
role?: string;
auth?: Auth;
isAnyImageOpen?: boolean;
authV2?: boolean;
};

export function checkModalRequired(params: checkModalParams): boolean {
const { auth, isAnyImageOpen, authV2 } = params;
const { role, auth, isAnyImageOpen, authV2 } = params;
// If authV2 is true, We try to use the iiif auth V2 services and fallback to V1 in case the manifest doesn't contain V2
const externalAccessService = authV2
? auth?.v2.externalAccessService || auth?.v1.externalAccessService
Expand All @@ -358,7 +359,11 @@ export function checkModalRequired(params: checkModalParams): boolean {
if (activeAccessService) {
return true;
} else if (externalAccessService) {
return !isAnyImageOpen;
if (isAnyImageOpen || role === 'StaffWithRestricted') {
return false;
} else {
return true;
}
} else {
return false;
}
Expand Down

0 comments on commit 1b5cfab

Please sign in to comment.