@veripass/react-sdk 1.0.18 → 1.0.20
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/react-sdk.cjs.js +13 -7
- package/dist/react-sdk.cjs.js.map +1 -1
- package/dist/react-sdk.esm.js +13 -7
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/react-sdk.cjs.js
CHANGED
|
@@ -586,6 +586,10 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
586
586
|
_useState2 = _slicedToArray(_useState, 2),
|
|
587
587
|
publicUrlsList = _useState2[0],
|
|
588
588
|
setPublicUrlsList = _useState2[1];
|
|
589
|
+
var _useState3 = React.useState(false),
|
|
590
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
591
|
+
isInitialized = _useState4[0],
|
|
592
|
+
setIsInitialized = _useState4[1];
|
|
589
593
|
|
|
590
594
|
// State to manage user data, persisted in local storage
|
|
591
595
|
var _useLocalStorage = useLocalStorage('veripass-user-data', null),
|
|
@@ -611,8 +615,8 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
611
615
|
React.Children.forEach(children, function (child) {
|
|
612
616
|
return extractPublicPaths(child);
|
|
613
617
|
});
|
|
614
|
-
|
|
615
|
-
|
|
618
|
+
setPublicUrlsList(publicPaths);
|
|
619
|
+
setIsInitialized(true);
|
|
616
620
|
}, [children]);
|
|
617
621
|
|
|
618
622
|
/**
|
|
@@ -666,12 +670,14 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
666
670
|
|
|
667
671
|
// Effect to redirect if user is null
|
|
668
672
|
React.useEffect(function () {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
+
if (isInitialized) {
|
|
674
|
+
var currentPath = window.location.pathname;
|
|
675
|
+
var isWhitelisted = publicUrlsList.includes(currentPath);
|
|
676
|
+
if (user === null && !isWhitelisted) {
|
|
677
|
+
window.location.replace('/auth/login');
|
|
678
|
+
}
|
|
673
679
|
}
|
|
674
|
-
}, [user, publicUrlsList]);
|
|
680
|
+
}, [user, publicUrlsList, isInitialized]);
|
|
675
681
|
|
|
676
682
|
/**
|
|
677
683
|
* Memoized value containing the user data and authentication functions.
|