Skip to content
Snippets Groups Projects
Verified Commit 392aa7af authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Include hooks to fetch auth status.

parent f32fe4fa
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!50Fix/authorization
This commit is part of merge request !50. Comments created here will be created in the context of that merge request.
import { Unauthorized } from 'components/NonAuthUser/Unauthorized/Unauthorized'; import { Unauthorized } from 'components/NonAuthUser/Unauthorized/Unauthorized';
import { useAuth } from 'hooks/useAuth';
import { useRole } from 'hooks/useRole';
import React, { ComponentType, FC } from 'react'; import React, { ComponentType, FC } from 'react';
interface WithAuthProps { interface WithAuthProps {
...@@ -25,8 +27,8 @@ export const withAuthorization = <T extends WithAuthProps = WithAuthProps>( ...@@ -25,8 +27,8 @@ export const withAuthorization = <T extends WithAuthProps = WithAuthProps>(
) => { ) => {
const { allowedRoles } = props as T; const { allowedRoles } = props as T;
const role = 'admin'; const [role] = useRole();
const isAuth = true; const [isAuth] = useAuth();
// props comes afterwards so the can override the default ones. // props comes afterwards so the can override the default ones.
return allowedRoles.includes(role) && isAuth ? ( return allowedRoles.includes(role) && isAuth ? (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment