Skip to content

Commit

Permalink
fix(rbac): changes made to the component
Browse files Browse the repository at this point in the history
  • Loading branch information
imjulianeral committed Sep 2, 2021
1 parent 34aa9ad commit c945a06
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/NextShield.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ export function NextShield<
const pathIsHybrid = verifyPath(hybridRoutes, pathname)
const pathIsAuthorized =
RBAC && userRole && verifyPath(RBAC[userRole].grantedRoutes, pathname)
const route = getAccessRoute(RBAC, userRole, accessRoute, loginRoute)

useEffect(() => {
if (!isAuth && !isLoading && pathIsPrivate) replace(loginRoute)
if (isAuth && !isLoading && pathIsPublic)
replace(getAccessRoute(RBAC, userRole, accessRoute, loginRoute))
replace(route)

if (isAuth && userRole && !isLoading && !pathIsHybrid && !pathIsAuthorized)
replace(getAccessRoute(RBAC, userRole, accessRoute, loginRoute))
replace(route)
}, [
replace,
userRole,
// RBAC,
route,
isAuth,
isLoading,
accessRoute,
loginRoute,
pathIsPrivate,
pathIsPublic,
Expand Down

0 comments on commit c945a06

Please sign in to comment.