Skip to content
Snippets Groups Projects

Change folder structure and fix auth flow.

Merged Defendi Alberto requested to merge rebase into dev
1 file
+ 2
4
Compare changes
  • Side-by-side
  • Inline
import React, { ComponentType, FC, useContext } from 'react';
import { BlurCircular } from '@material-ui/icons';
import { NonAuthRoutes } from 'api/routes';
import { AuthContext } from 'components/AuthUser/AuthContext';
import { Unauthorized } from 'components/NonAuthUser/Unauthorized/Unauthorized';
import { useAuth } from 'hooks/useAuth';
import { useRole } from 'hooks/useRole';
import { Redirect } from 'react-router-dom';
import { CircularProgressClassKey } from '@material-ui/core';
import { Unauthorized } from 'components/Unauthorized/Unauthorized';
import { AuthContext } from 'components/Auth/AuthContext';
const HandleIsAuth: FC<{ isAuth: boolean }> = ({ isAuth }) =>
isAuth ? (
@@ -21,10 +18,6 @@ interface WithAuthProps {
allowedRoles: string[];
}
interface Props extends WithAuthProps {
children: React.ReactNode;
}
/* eslint-disable react/jsx-props-no-spreading */
/**
*
@@ -45,7 +38,7 @@ export const withAuthorization = <T extends WithAuthProps = WithAuthProps>(
console.log(`ROLE ${role} AUTH ${isAuth}`);
/* eslint-disable no-nested-ternary */
return typeof isAuth === null || role === null ? (
return typeof isAuth === null && role === null ? (
<BlurCircular />
) : // props comes afterwards so the can override the default ones.
allowedRoles.includes(role) && isAuth ? (
Loading