Skip to content

Commit c7c5343

Browse files
added check for authentication.
1 parent dd7d139 commit c7c5343

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/components/utilities/PrivateRoute.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ export const PrivateRoute = ({ children, routeType }) => {
1515
}
1616

1717
dispatch(updateAccessToken(profile))
18-
19-
const isAuthenticated = !!profile?.clientPrincipal && !error
18+
const roles = profile?.clientPrincipal.userRoles
19+
const isAuthenticated =
20+
roles.includes('admin') || roles.includes('editor') || (roles.includes('readonly') && !error)
2021
const isAdmin = profile?.clientPrincipal.userRoles.includes('admin')
2122
if (routeType === 'admin') {
2223
return !isAdmin ? <Navigate to="/403" /> : children
2324
} else {
24-
return !isAuthenticated ? <Navigate to="/login" /> : children
25+
return !isAuthenticated ? <Navigate to="/403" /> : children
2526
}
2627
}
2728

0 commit comments

Comments
 (0)