@plasmicapp/react-web 0.2.148 → 0.2.149
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/dist/all.d.ts +10 -5
- package/dist/auth/PlasmicPageGuard.d.ts +2 -1
- package/dist/react-web.cjs.development.js +13 -7
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +13 -7
- package/dist/react-web.esm.js.map +1 -1
- package/package.json +5 -5
- package/skinny/dist/auth/PlasmicPageGuard.d.ts +2 -1
- package/skinny/dist/index.js +15 -10
- package/skinny/dist/index.js.map +1 -1
package/dist/react-web.esm.js
CHANGED
|
@@ -842,14 +842,17 @@ function _triggerLogin() {
|
|
|
842
842
|
function PlasmicPageGuard(props) {
|
|
843
843
|
var appId = props.appId,
|
|
844
844
|
authorizeEndpoint = props.authorizeEndpoint,
|
|
845
|
-
|
|
845
|
+
minRole = props.minRole,
|
|
846
|
+
canTriggerLogin = props.canTriggerLogin,
|
|
846
847
|
children = props.children;
|
|
847
848
|
var dataSourceCtxValue = usePlasmicDataSourceContext();
|
|
848
849
|
React__default.useEffect(function () {
|
|
849
|
-
if (
|
|
850
|
-
|
|
850
|
+
if (canTriggerLogin) {
|
|
851
|
+
if (dataSourceCtxValue && "isUserLoading" in dataSourceCtxValue && !dataSourceCtxValue.isUserLoading && !dataSourceCtxValue.user) {
|
|
852
|
+
triggerLogin(appId, authorizeEndpoint);
|
|
853
|
+
}
|
|
851
854
|
}
|
|
852
|
-
}, [dataSourceCtxValue, appId, authorizeEndpoint]);
|
|
855
|
+
}, [dataSourceCtxValue, appId, authorizeEndpoint, canTriggerLogin]);
|
|
853
856
|
function canUserViewPage() {
|
|
854
857
|
if (!dataSourceCtxValue) {
|
|
855
858
|
return false;
|
|
@@ -857,12 +860,15 @@ function PlasmicPageGuard(props) {
|
|
|
857
860
|
if (!dataSourceCtxValue.user) {
|
|
858
861
|
return false;
|
|
859
862
|
}
|
|
860
|
-
if (!("
|
|
863
|
+
if (!("roleIds" in dataSourceCtxValue.user)) {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
if (!Array.isArray(dataSourceCtxValue.user.roleIds)) {
|
|
861
867
|
return false;
|
|
862
868
|
}
|
|
863
|
-
return
|
|
869
|
+
return dataSourceCtxValue.user.roleIds.includes(minRole);
|
|
864
870
|
}
|
|
865
|
-
if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading || !dataSourceCtxValue.user) {
|
|
871
|
+
if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading || !dataSourceCtxValue.user && canTriggerLogin) {
|
|
866
872
|
return null;
|
|
867
873
|
}
|
|
868
874
|
if (!canUserViewPage()) {
|