Skip to content

Commit 19f16ec

Browse files
committed
fix(rbac): state debug
1 parent f30b4a4 commit 19f16ec

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
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.5",
14+
"next-shield": "^2.0.6",
1515
"react": "17.0.2",
1616
"react-dom": "17.0.2",
1717
"react-firebase-hooks": "^3.0.4",

src/components/NextShield.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,20 @@ export function NextShield<
6666
const access = getAccessRoute(RBAC, userRole, accessRoute, loginRoute)
6767

6868
useEffect(() => {
69-
console.log({ access, pathIsAuthorized })
70-
71-
if (!isAuth && !isLoading && pathIsPrivate) replace(loginRoute)
69+
if (!isAuth && !isLoading && pathIsPrivate) {
70+
console.log({
71+
userRole,
72+
access,
73+
isAuth,
74+
isLoading,
75+
loginRoute,
76+
pathIsPrivate,
77+
pathIsPublic,
78+
pathIsHybrid,
79+
pathIsAuthorized,
80+
})
81+
replace(loginRoute)
82+
}
7283
if (isAuth && !isLoading && pathIsPublic) replace(access)
7384
if (isAuth && userRole && !isLoading && !pathIsHybrid && !pathIsAuthorized)
7485
replace(access)

0 commit comments

Comments
 (0)