|
@ -2,7 +2,7 @@ |
|
|
import { Suspense, useContext, lazy } from 'react' |
|
|
import { Suspense, useContext, lazy } from 'react' |
|
|
|
|
|
|
|
|
// ** Utils
|
|
|
// ** Utils
|
|
|
import { isUserLoggedIn } from '@utils' |
|
|
|
|
|
|
|
|
import { isUserLoggedIn, getDefaultRoute } from '@utils' |
|
|
import { useLayout } from '@hooks/useLayout' |
|
|
import { useLayout } from '@hooks/useLayout' |
|
|
import { AbilityContext } from '@src/utility/context/Can' |
|
|
import { AbilityContext } from '@src/utility/context/Can' |
|
|
import { useRouterTransition } from '@hooks/useRouterTransition' |
|
|
import { useRouterTransition } from '@hooks/useRouterTransition' |
|
@ -85,11 +85,9 @@ const Router = () => { |
|
|
** If user is not Logged in & route.meta.authRoute, !route.meta.publicRoute are undefined |
|
|
** If user is not Logged in & route.meta.authRoute, !route.meta.publicRoute are undefined |
|
|
** Then redirect user to login |
|
|
** Then redirect user to login |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
return <Redirect to='/login' /> |
|
|
return <Redirect to='/login' /> |
|
|
} else if (route.meta && route.meta.authRoute && isUserLoggedIn()) { |
|
|
} else if (route.meta && route.meta.authRoute && isUserLoggedIn()) { |
|
|
// ** If route has meta and authRole and user is Logged in then redirect user to home page (DefaultRoute)
|
|
|
// ** If route has meta and authRole and user is Logged in then redirect user to home page (DefaultRoute)
|
|
|
|
|
|
|
|
|
return <Redirect to='/' /> |
|
|
return <Redirect to='/' /> |
|
|
// } else if (isUserLoggedIn() && !ability.can(action || 'read', resource)) {
|
|
|
// } else if (isUserLoggedIn() && !ability.can(action || 'read', resource)) {
|
|
|
// // ** If user is Logged in and doesn't have ability to visit the page redirect the user to Not Authorized
|
|
|
// // ** If user is Logged in and doesn't have ability to visit the page redirect the user to Not Authorized
|
|
@ -197,7 +195,7 @@ const Router = () => { |
|
|
exact |
|
|
exact |
|
|
path='/' |
|
|
path='/' |
|
|
render={() => { |
|
|
render={() => { |
|
|
return isUserLoggedIn() ? <Redirect to={DefaultRoute} /> : <Redirect to='/login' /> |
|
|
|
|
|
|
|
|
return isUserLoggedIn() ? <Redirect to={getDefaultRoute()} /> : <Redirect to='/login' /> |
|
|
}} |
|
|
}} |
|
|
/> |
|
|
/> |
|
|
{/* Not Auth Route */} |
|
|
{/* Not Auth Route */} |
|
|