Skip to content

Commit

Permalink
[Routes] Fix exact routing for protected routes
Browse files Browse the repository at this point in the history
For some reason the exact prop does not work when given directly to the wrapped Route component
  • Loading branch information
rikurauhala committed Nov 27, 2024
1 parent c2583e5 commit 98926ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion services/frontend/src/components/Routes/ProtectedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ProtectedRoute = ({
}

if (hasAccessToRoute()) {
return <Route component={component} exact location={location} path={path} {...rest} />
return <Route component={component} location={location} path={path} {...rest} />
}

return <AccessDeniedMessage />
Expand Down
17 changes: 14 additions & 3 deletions services/frontend/src/components/Routes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,34 @@ export const Routes = () => (
{isDefaultServiceProvider() && <Route component={Feedback} exact path={routes.feedback} />}
<ProtectedRoute
component={PopulationStatistics}
exact
path={routes.populations}
requireUserHasRights
requiredRoles={['fullSisuAccess']}
/>
<ProtectedRoute
component={FacultyStatistics}
exact
path={routes.faculties}
requiredRoles={['admin', 'fullSisuAccess', 'facultyStatistics']}
/>
<ProtectedRoute
component={StudyProgramme}
exact
path={routes.studyProgramme}
requireUserHasRights
requiredRoles={['fullSisuAccess']}
/>
<ProtectedRoute
component={StudentStatistics}
exact
path={routes.students}
requireUserHasRights
requiredRoles={['admin', 'fullSisuAccess', 'studyGuidanceGroups']}
/>
<ProtectedRoute
component={CourseStatistics}
exact
path={routes.courseStatistics}
requireUserHasRights
requiredRoles={['fullSisuAccess', 'courseStatistics']}
Expand All @@ -86,42 +91,48 @@ export const Routes = () => (
{isDefaultServiceProvider() && (
<ProtectedRoute
component={CoursePopulation}
exact
path={routes.coursepopulation}
requireUserHasRights
requiredRoles={['fullSisuAccess']}
/>
)}
<ProtectedRoute
component={CustomPopulation}
exact
path={routes.custompopulation}
requireUserHasRights
requiredRoles={['admin', 'fullSisuAccess', 'studyGuidanceGroups']}
/>
{isDefaultServiceProvider() && (
<ProtectedRoute
component={CustomOpenUniPopulation}
exact
path={routes.customOpenUniPopulation}
requiredRoles={['admin', 'openUniSearch']}
/>
)}
<ProtectedRoute component={CompletedCourses} path={routes.completedCoursesSearch} />
<ProtectedRoute component={Updater} path={routes.updater} requireUserHasRights requiredRoles={['admin']} />
<ProtectedRoute component={CompletedCourses} exact path={routes.completedCoursesSearch} />
<ProtectedRoute component={Updater} exact path={routes.updater} requireUserHasRights requiredRoles={['admin']} />
<ProtectedRoute
component={StudyGuidanceGroups}
exact
path={routes.studyGuidanceGroups}
requiredRoles={['studyGuidanceGroups']}
/>
{languageCenterViewEnabled && (
<ProtectedRoute
component={LanguageCenterView}
exact
path={routes.languageCenterView}
requireUserHasRights
requiredRoles={['admin']}
/>
)}
<ProtectedRoute component={University} path={routes.university} />
<ProtectedRoute component={University} exact path={routes.university} />
<ProtectedRoute
component={CloseToGraduation}
exact
path={routes.closeToGraduation}
requiredRoles={['fullSisuAccess', 'studyGuidanceGroups']}
/>
Expand Down

0 comments on commit 98926ae

Please sign in to comment.