@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.esm.js
CHANGED
|
@@ -566,6 +566,10 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
566
566
|
_useState2 = _slicedToArray(_useState, 2),
|
|
567
567
|
publicUrlsList = _useState2[0],
|
|
568
568
|
setPublicUrlsList = _useState2[1];
|
|
569
|
+
var _useState3 = useState(false),
|
|
570
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
571
|
+
isInitialized = _useState4[0],
|
|
572
|
+
setIsInitialized = _useState4[1];
|
|
569
573
|
|
|
570
574
|
// State to manage user data, persisted in local storage
|
|
571
575
|
var _useLocalStorage = useLocalStorage('veripass-user-data', null),
|
|
@@ -591,8 +595,8 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
591
595
|
React__default.Children.forEach(children, function (child) {
|
|
592
596
|
return extractPublicPaths(child);
|
|
593
597
|
});
|
|
594
|
-
|
|
595
|
-
|
|
598
|
+
setPublicUrlsList(publicPaths);
|
|
599
|
+
setIsInitialized(true);
|
|
596
600
|
}, [children]);
|
|
597
601
|
|
|
598
602
|
/**
|
|
@@ -646,12 +650,14 @@ var AuthProvider = function AuthProvider(_ref) {
|
|
|
646
650
|
|
|
647
651
|
// Effect to redirect if user is null
|
|
648
652
|
useEffect(function () {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
+
if (isInitialized) {
|
|
654
|
+
var currentPath = window.location.pathname;
|
|
655
|
+
var isWhitelisted = publicUrlsList.includes(currentPath);
|
|
656
|
+
if (user === null && !isWhitelisted) {
|
|
657
|
+
window.location.replace('/auth/login');
|
|
658
|
+
}
|
|
653
659
|
}
|
|
654
|
-
}, [user, publicUrlsList]);
|
|
660
|
+
}, [user, publicUrlsList, isInitialized]);
|
|
655
661
|
|
|
656
662
|
/**
|
|
657
663
|
* Memoized value containing the user data and authentication functions.
|