diff --git a/.gitignore b/.gitignore index 57c0587..a32ab0c 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,5 @@ tests/playwright-report/ # Dummy /dump +jwt-auth-inject.json +platform/app/dist.zip diff --git a/platform/app/src/routes/WorkList/WorkList.tsx b/platform/app/src/routes/WorkList/WorkList.tsx index 50c8a4b..2e05fae 100644 --- a/platform/app/src/routes/WorkList/WorkList.tsx +++ b/platform/app/src/routes/WorkList/WorkList.tsx @@ -85,6 +85,38 @@ function WorkList({ const debouncedFilterValues = useDebounce(filterValues, 200); const { resultsPerPage, pageNumber, sortBy, sortDirection } = filterValues; + /* + * Patch untuk Role checking patient gabisa akses ke study list + */ + const token = window.sessionStorage.getItem('ohif-auth-token'); + if (!token) { + return; + } + const decodedToken = decodeToken(token); + + // Check jika 'role' = 'patient' tapi akses '/' return ke viewer + if (decodedToken && decodedToken.role === 'patient') { + const currentPath = window.location.pathname + window.location.search; + if (currentPath === '/') { + console.log( + 'User is a patient and trying to access the root path. Redirecting to his/her home URL.' + ); + window.location.href = `${decodedToken.home_url}`; + } + } + + function decodeToken(token) { + try { + const payload = token.split('.')[1]; + if (payload) { + return JSON.parse(atob(payload)); + } + } catch (e) { + console.error('Error parsing JWT token', e); + } + return null; + } + /* * The default sort value keep the filters synchronized with runtime conditional sorting * Only applied if no other sorting is specified and there are less than 101 studies @@ -542,7 +574,7 @@ function WorkList({ /> -
+
dataSourceConfigurationComponent() // : undefined // } - getDataSourceConfigurationComponent={ - undefined - } + getDataSourceConfigurationComponent={undefined} />
{hasStudies ? (