From c7c53439e3452247ec057019cc749a33bb5fd1d5 Mon Sep 17 00:00:00 2001
From: KelvinTegelaar <49186168+KelvinTegelaar@users.noreply.github.com>
Date: Mon, 17 Jan 2022 13:24:27 +0100
Subject: [PATCH] added check for authentication.
---
src/components/utilities/PrivateRoute.js | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/components/utilities/PrivateRoute.js b/src/components/utilities/PrivateRoute.js
index cd296290dc3f..61ebff149e8d 100644
--- a/src/components/utilities/PrivateRoute.js
+++ b/src/components/utilities/PrivateRoute.js
@@ -15,13 +15,14 @@ export const PrivateRoute = ({ children, routeType }) => {
}
dispatch(updateAccessToken(profile))
-
- const isAuthenticated = !!profile?.clientPrincipal && !error
+ const roles = profile?.clientPrincipal.userRoles
+ const isAuthenticated =
+ roles.includes('admin') || roles.includes('editor') || (roles.includes('readonly') && !error)
const isAdmin = profile?.clientPrincipal.userRoles.includes('admin')
if (routeType === 'admin') {
return !isAdmin ? : children
} else {
- return !isAuthenticated ? : children
+ return !isAuthenticated ? : children
}
}