@veripass/react-sdk 1.0.19 → 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.
@@ -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),
@@ -612,6 +616,7 @@ var AuthProvider = function AuthProvider(_ref) {
612
616
  return extractPublicPaths(child);
613
617
  });
614
618
  setPublicUrlsList(publicPaths);
619
+ setIsInitialized(true);
615
620
  }, [children]);
616
621
 
617
622
  /**
@@ -665,12 +670,14 @@ var AuthProvider = function AuthProvider(_ref) {
665
670
 
666
671
  // Effect to redirect if user is null
667
672
  React.useEffect(function () {
668
- var currentPath = window.location.pathname;
669
- var isWhitelisted = publicUrlsList.includes(currentPath);
670
- if (user === null && !isWhitelisted) {
671
- window.location.replace('/auth/login');
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
+ }
672
679
  }
673
- }, [user, publicUrlsList]);
680
+ }, [user, publicUrlsList, isInitialized]);
674
681
 
675
682
  /**
676
683
  * Memoized value containing the user data and authentication functions.