diff --git a/client/src/modules/Course/contexts/SessionContext.tsx b/client/src/modules/Course/contexts/SessionContext.tsx index b60c13db0e..69cebdcae3 100644 --- a/client/src/modules/Course/contexts/SessionContext.tsx +++ b/client/src/modules/Course/contexts/SessionContext.tsx @@ -8,6 +8,7 @@ import Router from 'next/router'; import React, { useEffect } from 'react'; import { useAsync } from 'react-use'; import { useActiveCourseContext } from './ActiveCourseContext'; +import { hasRoleInAnyCourse } from 'domain/user'; export const SessionContext = React.createContext({} as Session); @@ -17,10 +18,11 @@ type Props = React.PropsWithChildren<{ allowedRoles?: CourseRole[]; course?: ProfileCourseDto; adminOnly?: boolean; + anyCoursePowerUser?: boolean; }>; export function SessionProvider(props: Props) { - const { allowedRoles } = props; + const { allowedRoles, anyCoursePowerUser } = props; const activeCourse = useActiveCourseContext().course; const course = props.course ?? activeCourse; @@ -66,7 +68,10 @@ export function SessionProvider(props: Props) { if (!isAdmin) { const roles = courses?.[id]?.roles ?? []; - if (!allowedRoles.some(role => roles.includes(role))) { + const hasRoleInCurrentCourse = allowedRoles.some(role => roles.includes(role)); + const isAnyCoursePowerUser = anyCoursePowerUser && allowedRoles.some(role => hasRoleInAnyCourse(session, role)); + + if (!hasRoleInCurrentCourse && !isAnyCoursePowerUser) { return ( ) { export default function () { return ( - + diff --git a/client/src/pages/admin/events.tsx b/client/src/pages/admin/events.tsx index 81f9d37eae..b024f5b7ce 100644 --- a/client/src/pages/admin/events.tsx +++ b/client/src/pages/admin/events.tsx @@ -213,7 +213,7 @@ function getInitialValues(modalData: Partial) { export default function () { return ( - + diff --git a/client/src/pages/admin/mentor-registry.tsx b/client/src/pages/admin/mentor-registry.tsx index 1bb7f8359e..baeab06346 100644 --- a/client/src/pages/admin/mentor-registry.tsx +++ b/client/src/pages/admin/mentor-registry.tsx @@ -270,7 +270,7 @@ function filterData(data: MentorRegistryDto[], showAll: boolean) { export default function () { return ( - + diff --git a/client/src/pages/admin/tasks.tsx b/client/src/pages/admin/tasks.tsx index 333432dd8a..2fde3c7aed 100644 --- a/client/src/pages/admin/tasks.tsx +++ b/client/src/pages/admin/tasks.tsx @@ -5,7 +5,7 @@ import { TasksPage } from 'modules/Tasks/pages'; export default function () { return ( - + diff --git a/client/src/pages/admin/users.tsx b/client/src/pages/admin/users.tsx index 3cdbcf3666..c600608d33 100644 --- a/client/src/pages/admin/users.tsx +++ b/client/src/pages/admin/users.tsx @@ -79,7 +79,7 @@ function Page() { export default function () { return ( - +