From 392aa7af4734310c2271e09a435d02e590ebcbef Mon Sep 17 00:00:00 2001
From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it>
Date: Thu, 27 May 2021 09:21:11 +0200
Subject: [PATCH] Include hooks to fetch auth status.

---
 src/components/Authorization/Authorization.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/components/Authorization/Authorization.tsx b/src/components/Authorization/Authorization.tsx
index 5cf6d15..66ef96a 100644
--- a/src/components/Authorization/Authorization.tsx
+++ b/src/components/Authorization/Authorization.tsx
@@ -1,4 +1,6 @@
 import { Unauthorized } from 'components/NonAuthUser/Unauthorized/Unauthorized';
+import { useAuth } from 'hooks/useAuth';
+import { useRole } from 'hooks/useRole';
 import React, { ComponentType, FC } from 'react';
 
 interface WithAuthProps {
@@ -25,8 +27,8 @@ export const withAuthorization = <T extends WithAuthProps = WithAuthProps>(
   ) => {
     const { allowedRoles } = props as T;
 
-    const role = 'admin';
-    const isAuth = true;
+    const [role] = useRole();
+    const [isAuth] = useAuth();
 
     // props comes afterwards so the can override the default ones.
     return allowedRoles.includes(role) && isAuth ? (
-- 
GitLab