@veripass/react-sdk 1.0.11 → 1.0.12

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.
@@ -566,6 +566,8 @@ var AuthContext = /*#__PURE__*/React.createContext();
566
566
  */
567
567
  var AuthProvider = function AuthProvider(_ref) {
568
568
  var children = _ref.children;
569
+ var whitelistUrls = ['/auth/login', '/auth/signup'];
570
+
569
571
  // State to manage user data, persisted in local storage
570
572
  var _useLocalStorage = useLocalStorage('veripass-user-data', null),
571
573
  _useLocalStorage2 = _slicedToArray(_useLocalStorage, 2),
@@ -574,7 +576,7 @@ var AuthProvider = function AuthProvider(_ref) {
574
576
 
575
577
  /**
576
578
  * Logs in the user by saving their data to local storage and navigating to the admin page.
577
- *
579
+ *
578
580
  * @param {object} user - The user data to be stored.
579
581
  */
580
582
  var login = /*#__PURE__*/function () {
@@ -608,7 +610,7 @@ var AuthProvider = function AuthProvider(_ref) {
608
610
 
609
611
  /**
610
612
  * Retrieves the stored user data (token) from local storage.
611
- *
613
+ *
612
614
  * @returns {object|null} The user data stored in local storage, or null if not found.
613
615
  */
614
616
  var getToken = function getToken() {
@@ -618,7 +620,9 @@ var AuthProvider = function AuthProvider(_ref) {
618
620
 
619
621
  // Effect to redirect if user is null
620
622
  React.useEffect(function () {
621
- if (user === null) {
623
+ var currentPath = window.location.pathname;
624
+ var isWhitelisted = whitelistUrls.includes(currentPath);
625
+ if (user === null && !isWhitelisted) {
622
626
  window.location.replace('/auth/login');
623
627
  }
624
628
  }, [user]);
@@ -649,7 +653,7 @@ var AuthProvider = function AuthProvider(_ref) {
649
653
 
650
654
  /**
651
655
  * Custom hook to access the authentication context.
652
- *
656
+ *
653
657
  * @returns {AuthContextValue} The authentication context value, including user data, login, logout, and getToken functions.
654
658
  */
655
659
  var useAuth = function useAuth() {