@insforge/react 1.0.2-dev.11 → 1.0.2-dev.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.
package/dist/index.js CHANGED
@@ -544,7 +544,16 @@ var InsforgeManager = class _InsforgeManager {
544
544
  // Called after hydration to get complete user information beyond what's in cookies
545
545
  async loadAuthState() {
546
546
  try {
547
- console.log("[InsforgeManager] loadAuthState() - calling getCurrentUser()");
547
+ const { isLoggedIn } = await this.sdk.auth.restoreSession();
548
+ if (!isLoggedIn) {
549
+ this.user = null;
550
+ if (this.config.onAuthChange) {
551
+ this.config.onAuthChange(null);
552
+ }
553
+ this.isLoaded = true;
554
+ this.notifyListeners();
555
+ return { success: false, error: "no_session" };
556
+ }
548
557
  const userResult = await this.sdk.auth.getCurrentUser();
549
558
  if (userResult.data) {
550
559
  const profile = userResult.data.profile;
@@ -556,7 +565,6 @@ var InsforgeManager = class _InsforgeManager {
556
565
  // You can add more profile fields here as needed
557
566
  };
558
567
  this.user = userData;
559
- console.log("[InsforgeManager] loadAuthState() - user loaded:", userData.email);
560
568
  if (this.config.onAuthChange) {
561
569
  this.config.onAuthChange(userData);
562
570
  }
@@ -564,17 +572,15 @@ var InsforgeManager = class _InsforgeManager {
564
572
  this.notifyListeners();
565
573
  return { success: true };
566
574
  } else {
567
- console.log("[InsforgeManager] loadAuthState() - no user data, error:", userResult.error);
568
575
  this.user = null;
569
576
  if (this.config.onAuthChange) {
570
577
  this.config.onAuthChange(null);
571
578
  }
572
579
  this.isLoaded = true;
573
580
  this.notifyListeners();
574
- return { success: false, error: userResult.error?.message || "no_session" };
581
+ return { success: false, error: userResult.error?.message || "failed_to_get_user" };
575
582
  }
576
583
  } catch (error) {
577
- console.error("[InsforgeManager] loadAuthState() catch error:", error);
578
584
  this.user = null;
579
585
  if (this.config.onAuthChange) {
580
586
  this.config.onAuthChange(null);