From a1238c25047f0f4001e590ee19f67d6129d8ff40 Mon Sep 17 00:00:00 2001
From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it>
Date: Thu, 15 Apr 2021 09:40:14 +0200
Subject: [PATCH] Check if user has required role

---
 src/components/api/PrivateRoute/PrivateRoute.tsx | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/components/api/PrivateRoute/PrivateRoute.tsx b/src/components/api/PrivateRoute/PrivateRoute.tsx
index e313633..7c32561 100644
--- a/src/components/api/PrivateRoute/PrivateRoute.tsx
+++ b/src/components/api/PrivateRoute/PrivateRoute.tsx
@@ -18,9 +18,8 @@ export const PrivateRoute = ({
   path,
   requiredRoles,
 }: Props): JSX.Element => {
-  const isAuthed = false;
+  const isAuthed = true;
   const userHasRequiredRole = requiredRoles.includes('admin');
-
   const message = userHasRequiredRole
     ? 'Please log in to view this page'
     : 'Your role is not allowed';
@@ -29,7 +28,7 @@ export const PrivateRoute = ({
       exact={false}
       path={path}
       render={(props: RouteProps) =>
-        isAuthed ? (
+        isAuthed && userHasRequiredRole ? (
           <Component {...props} />
         ) : (
           <Redirect
-- 
GitLab