@axcode/axcloud-sdk 0.1.7-dev.cc5cc69 → 0.2.0-dev.03fb26c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -31
- package/dist/index.d.mts +31 -7
- package/dist/index.d.ts +31 -7
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2153,7 +2153,7 @@ function ProtectedRoute({
|
|
|
2153
2153
|
returnTo
|
|
2154
2154
|
}) {
|
|
2155
2155
|
const { isAuthenticated, isLoading: isAuthLoading, login } = useAuth();
|
|
2156
|
-
const {
|
|
2156
|
+
const { role, isLoading: isUserLoading } = useUser();
|
|
2157
2157
|
const isLoading = isAuthLoading || isAuthenticated && isUserLoading;
|
|
2158
2158
|
if (isLoading) {
|
|
2159
2159
|
return /* @__PURE__ */ jsx(Fragment, { children: loadingComponent ?? /* @__PURE__ */ jsx(DefaultLoadingComponent, {}) });
|
|
@@ -2165,9 +2165,9 @@ function ProtectedRoute({
|
|
|
2165
2165
|
}
|
|
2166
2166
|
return /* @__PURE__ */ jsx(Fragment, { children: unauthenticatedComponent ?? /* @__PURE__ */ jsx(DefaultUnauthenticatedComponent, {}) });
|
|
2167
2167
|
}
|
|
2168
|
-
if (roles
|
|
2168
|
+
if (roles) {
|
|
2169
2169
|
const requiredRoles = Array.isArray(roles) ? roles : [roles];
|
|
2170
|
-
const hasRequiredRole = requiredRoles.includes(role);
|
|
2170
|
+
const hasRequiredRole = role !== null && role !== void 0 && requiredRoles.includes(role);
|
|
2171
2171
|
if (!hasRequiredRole) {
|
|
2172
2172
|
return /* @__PURE__ */ jsx(Fragment, { children: unauthorizedComponent ?? /* @__PURE__ */ jsx(DefaultUnauthorizedComponent, {}) });
|
|
2173
2173
|
}
|