Skip to content

Commit 043b6d3

Browse files
committed
Revert "Merge pull request #2298 from KelvinTegelaar/dev"
This reverts commit e3cb141, reversing changes made to 1c3eb56.
1 parent e3cb141 commit 043b6d3

22 files changed

+1297
-2073
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cipp",
3-
"version": "5.4.1",
3+
"version": "5.4.0",
44
"description": "The CyberDrain Improved Partner Portal is a portal to help manage administration for Microsoft Partners.",
55
"homepage": "https://cipp.app/",
66
"bugs": {

public/version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.4.1
1+
5.4.0

src/App.jsx

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,30 @@ import React, { Suspense } from 'react'
22
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom'
33
import { PrivateRoute, FullScreenLoading, ErrorBoundary } from 'src/components/utilities'
44
import 'src/scss/style.scss'
5+
import routes from 'src/routes'
56
import { Helmet } from 'react-helmet-async'
7+
import adminRoutes from './adminRoutes'
68
import Skeleton from 'react-loading-skeleton'
79
import TimeAgo from 'javascript-time-ago'
810
import en from 'javascript-time-ago/locale/en.json'
911
TimeAgo.addDefaultLocale(en)
1012
import { library } from '@fortawesome/fontawesome-svg-core'
1113
import { fas } from '@fortawesome/free-solid-svg-icons'
12-
import routes from 'src/routes'
13-
import { useAuthCheck } from './components/utilities/CippauthCheck'
1414

1515
library.add(fas)
16-
const dynamicImport = (path) => React.lazy(() => import(`./${path}`))
16+
17+
// Containers
1718
const DefaultLayout = React.lazy(() => import('./layout/DefaultLayout'))
19+
20+
// Pages
1821
const Page401 = React.lazy(() => import('./views/pages/page401/Page401'))
1922
const Page403 = React.lazy(() => import('./views/pages/page403/Page403'))
2023
const Page404 = React.lazy(() => import('./views/pages/page404/Page404'))
2124
const Page500 = React.lazy(() => import('./views/pages/page500/Page500'))
2225
const PageLogOut = React.lazy(() => import('src/views/pages/LogoutRedirect/PageLogOut'))
2326
const Login = React.lazy(() => import('./views/pages/login/Login'))
2427
const Logout = React.lazy(() => import('./views/pages/login/Logout'))
28+
2529
const App = () => {
2630
return (
2731
<BrowserRouter>
@@ -46,23 +50,43 @@ const App = () => {
4650
}
4751
>
4852
{routes.map((route, idx) => {
49-
const Component = dynamicImport(route.component)
50-
const allowedRoles = route.allowedRoles
5153
return (
52-
Component && (
54+
route.component && (
55+
<Route
56+
key={`route-${idx}`}
57+
path={route.path}
58+
exact={route.exact}
59+
name={route.name}
60+
element={
61+
<Suspense fallback={<Skeleton />}>
62+
<Helmet>
63+
<title>CIPP - {route.name}</title>
64+
</Helmet>
65+
<ErrorBoundary key={route.name}>
66+
<route.component />
67+
</ErrorBoundary>
68+
</Suspense>
69+
}
70+
/>
71+
)
72+
)
73+
})}
74+
{adminRoutes.map((route, idx) => {
75+
return (
76+
route.component && (
5377
<Route
5478
key={`route-${idx}`}
5579
path={route.path}
5680
exact={route.exact}
5781
name={route.name}
5882
element={
59-
<PrivateRoute allowedRoles={allowedRoles}>
83+
<PrivateRoute routeType="admin">
6084
<Suspense fallback={<Skeleton />}>
6185
<Helmet>
6286
<title>CIPP - {route.name}</title>
6387
</Helmet>
6488
<ErrorBoundary key={route.name}>
65-
<Component />
89+
<route.component />
6690
</ErrorBoundary>
6791
</Suspense>
6892
</PrivateRoute>

src/adminRoutes.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import React from 'react'
2+
3+
const CIPPSettings = React.lazy(() => import('src/views/cipp/app-settings/CIPPSettings'))
4+
const Setup = React.lazy(() => import('src/views/cipp/Setup'))
5+
const ApplyStandard = React.lazy(() => import('src/views/tenant/standards/ListStandards'))
6+
const GDAPStatus = React.lazy(() => import('src/views/tenant/administration/ListGDAPQueue'))
7+
const GDAP = React.lazy(() => import('src/views/tenant/administration/GDAPWizard'))
8+
const GDAPInvite = React.lazy(() => import('src/views/tenant/administration/GDAPInviteWizard'))
9+
const GDAPRoleWizard = React.lazy(() => import('src/views/tenant/administration/GDAPRoleWizard'))
10+
const GDAPRoles = React.lazy(() => import('src/views/tenant/administration/ListGDAPRoles'))
11+
const GDAPRelationships = React.lazy(() =>
12+
import('./views/tenant/administration/ListGDAPRelationships'),
13+
)
14+
const appapproval = React.lazy(() => import('src/views/cipp/AppApproval'))
15+
const TenantOffboardingWizard = React.lazy(() =>
16+
import('src/views/tenant/administration/TenantOffboardingWizard'),
17+
)
18+
const TenantOnboardingWizard = React.lazy(() =>
19+
import('src/views/tenant/administration/TenantOnboardingWizard'),
20+
)
21+
22+
const adminRoutes = [
23+
{ path: '/cipp', name: 'CIPP' },
24+
{ path: '/cipp/cipp', name: 'CIPP' },
25+
{ path: '/cipp/settings', name: 'Settings', component: CIPPSettings },
26+
{ path: '/cipp/setup', name: 'Setup', component: Setup },
27+
28+
{ path: '/tenant/administration/gdap', name: 'GDAP Wizard', component: GDAP },
29+
{
30+
path: '/tenant/administration/gdap-invite',
31+
name: 'GDAP Invite Wizard',
32+
component: GDAPInvite,
33+
},
34+
{
35+
path: '/tenant/administration/gdap-role-wizard',
36+
name: 'GDAP Role Wizard',
37+
component: GDAPRoleWizard,
38+
},
39+
{
40+
path: '/tenant/administration/gdap-roles',
41+
name: 'GDAP Roles',
42+
component: GDAPRoles,
43+
},
44+
{
45+
path: '/tenant/administration/gdap-relationships',
46+
name: 'GDAP Relationships',
47+
component: GDAPRelationships,
48+
},
49+
{
50+
path: '/tenant/administration/appapproval',
51+
name: 'App Approval',
52+
component: appapproval,
53+
},
54+
{
55+
path: '/tenant/administration/gdap-status',
56+
name: 'GDAP Status',
57+
component: GDAPStatus,
58+
},
59+
{
60+
path: '/tenant/standards/list-standards',
61+
name: 'List Standard',
62+
component: ApplyStandard,
63+
},
64+
{
65+
path: '/tenant/administration/tenant-offboarding-wizard',
66+
name: 'Tenant Offboarding',
67+
component: TenantOffboardingWizard,
68+
},
69+
{
70+
path: '/tenant/administration/tenant-onboarding-wizard',
71+
name: 'Tenant Onboarding',
72+
component: TenantOnboardingWizard,
73+
},
74+
]
75+
76+
export default adminRoutes

src/components/forms/RFFComponents.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,10 @@ export const RFFCFormInput = ({
150150
spellCheck = true,
151151
autoFocus = false,
152152
hiddenValue,
153-
defaultValue,
154153
onChange,
155154
}) => {
156155
return (
157-
<Field defaultValue={defaultValue} initialValue={hiddenValue} name={name} validate={validate}>
156+
<Field initialValue={hiddenValue} name={name} validate={validate}>
158157
{({ input, meta }) => {
159158
const handleChange = onChange
160159
? (e) => {

src/components/layout/AppSidebar.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import { AppSidebarNav } from 'src/components/layout'
1212
import SimpleBar from 'simplebar-react'
1313
import 'simplebar/dist/simplebar.min.css'
1414
import navigation from 'src/_nav'
15-
import { useAuthCheck } from '../utilities/CippauthCheck'
16-
import routes from 'src/routes'
17-
import { useRouteNavCompare } from 'src/hooks/useRouteNavCompare'
18-
import { useNavFavouriteCheck } from 'src/hooks/useNavFavouriteCheck'
1915

2016
const AppSidebar = () => {
2117
const i =
@@ -26,8 +22,6 @@ const AppSidebar = () => {
2622
if (!i.includes('JGySCBt1QXmNc')) {
2723
throw ''
2824
}
29-
const newNav = useRouteNavCompare(navigation)
30-
const navwithFavourites = useNavFavouriteCheck(newNav)
3125
return (
3226
<CSidebar
3327
onVisibleChange={(visible) => {
@@ -47,7 +41,7 @@ const AppSidebar = () => {
4741
/>
4842
<CSidebarNav>
4943
<SimpleBar>
50-
<AppSidebarNav items={navwithFavourites} />
44+
<AppSidebarNav items={navigation} />
5145
</SimpleBar>
5246
</CSidebarNav>
5347
</CSidebar>

src/components/tables/CellTable.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ export default function cellTable(
2020
columnProp = column
2121
}
2222

23-
if (
24-
!Array.isArray(columnProp) &&
25-
typeof columnProp === 'object' &&
26-
columnProp !== undefined &&
27-
columnProp !== null
28-
) {
23+
if (!Array.isArray(columnProp) && typeof columnProp === 'object') {
2924
columnProp = Object.keys(columnProp).map((key) => {
3025
return {
3126
[key]: columnProp[key],

src/components/utilities/CippauthCheck.jsx

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
import React from 'react'
2+
import { Navigate } from 'react-router-dom'
3+
import { useLoadClientPrincipalQuery } from 'src/store/api/auth'
24
import { FullScreenLoading } from 'src/components/utilities'
5+
import { useDispatch } from 'react-redux'
6+
import { updateAccessToken } from 'src/store/features/auth'
37
import PropTypes from 'prop-types'
4-
import { useAuthCheck } from './CippauthCheck'
58

6-
export const PrivateRoute = ({ children, allowedRoles }) => {
7-
const { isLoading, component: authComponent } = useAuthCheck(allowedRoles)
8-
if (isLoading) {
9+
export const PrivateRoute = ({ children, routeType }) => {
10+
const dispatch = useDispatch()
11+
const { data: profile, error, isFetching } = useLoadClientPrincipalQuery()
12+
//console.log()
13+
if (isFetching) {
914
return <FullScreenLoading />
1015
}
11-
if (authComponent) {
12-
return authComponent
16+
17+
dispatch(updateAccessToken(profile))
18+
let roles = null
19+
if (null !== profile?.clientPrincipal) {
20+
roles = profile?.clientPrincipal.userRoles
21+
} else if (null === profile?.clientPrincipal) {
22+
return <Navigate to={`/login?redirect_uri=${window.location.href}`} />
23+
}
24+
if (null === roles) {
25+
return <Navigate to={`/login?redirect_uri=${window.location.href}`} />
26+
} else {
27+
const isAuthenticated =
28+
roles.includes('admin') || roles.includes('editor') || (roles.includes('readonly') && !error)
29+
const isAdmin = roles.includes('admin')
30+
if (routeType === 'admin') {
31+
return !isAdmin ? <Navigate to="/403" /> : children
32+
} else {
33+
return !isAuthenticated ? <Navigate to="/403" /> : children
34+
}
1335
}
14-
return children
1536
}
1637

1738
PrivateRoute.propTypes = {
18-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]).isRequired,
19-
allowedRoles: PropTypes.arrayOf(PropTypes.string),
39+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
40+
routeType: PropTypes.string,
2041
}

0 commit comments

Comments
 (0)