Skip to content

Commit f30b4a4

Browse files
committed
fix(rbac): rerenders
1 parent cd6d366 commit f30b4a4

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

example/ts-fire-example/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/ts-fire-example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"firebase": "^8.7.0",
1313
"next": "11.0.1",
14-
"next-shield": "^2.0.4",
14+
"next-shield": "^2.0.5",
1515
"react": "17.0.2",
1616
"react-dom": "17.0.2",
1717
"react-firebase-hooks": "^3.0.4",

src/components/NextShield.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,12 @@ export function NextShield<
6666
const access = getAccessRoute(RBAC, userRole, accessRoute, loginRoute)
6767

6868
useEffect(() => {
69+
console.log({ access, pathIsAuthorized })
70+
6971
if (!isAuth && !isLoading && pathIsPrivate) replace(loginRoute)
70-
if (isAuth && !isLoading && pathIsPublic) {
71-
console.log('redirected to private route', { access, pathIsAuthorized })
72-
replace(access)
73-
}
74-
if (isAuth && userRole && !isLoading && !pathIsHybrid && !pathIsAuthorized) {
75-
console.log('redirected to granted route', { access, pathIsAuthorized })
72+
if (isAuth && !isLoading && pathIsPublic) replace(access)
73+
if (isAuth && userRole && !isLoading && !pathIsHybrid && !pathIsAuthorized)
7674
replace(access)
77-
}
7875
}, [
7976
replace,
8077
userRole,

0 commit comments

Comments
 (0)