@insforge/react 1.0.2-dev.1 → 1.0.2-dev.10
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.cjs +6 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -43
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -514,15 +514,7 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
514
514
|
}
|
|
515
515
|
this.isInitializing = true;
|
|
516
516
|
try {
|
|
517
|
-
|
|
518
|
-
const hasToken = !!sessionResult.data?.session?.accessToken;
|
|
519
|
-
if (hasToken) {
|
|
520
|
-
await this.loadAuthState();
|
|
521
|
-
} else if (this.user === void 0) {
|
|
522
|
-
this.user = null;
|
|
523
|
-
this.isLoaded = true;
|
|
524
|
-
this.notifyListeners();
|
|
525
|
-
}
|
|
517
|
+
await this.loadAuthState();
|
|
526
518
|
} finally {
|
|
527
519
|
this.isInitializing = false;
|
|
528
520
|
}
|
|
@@ -552,18 +544,7 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
552
544
|
// Called after hydration to get complete user information beyond what's in cookies
|
|
553
545
|
async loadAuthState() {
|
|
554
546
|
try {
|
|
555
|
-
|
|
556
|
-
const session = sessionResult.data?.session;
|
|
557
|
-
const token2 = session?.accessToken || null;
|
|
558
|
-
if (!token2) {
|
|
559
|
-
this.user = null;
|
|
560
|
-
if (this.config.onAuthChange) {
|
|
561
|
-
this.config.onAuthChange(null);
|
|
562
|
-
}
|
|
563
|
-
this.isLoaded = true;
|
|
564
|
-
this.notifyListeners();
|
|
565
|
-
return { success: false, error: "no_session" };
|
|
566
|
-
}
|
|
547
|
+
console.log("[InsforgeManager] loadAuthState() - calling getCurrentUser()");
|
|
567
548
|
const userResult = await this.sdk.auth.getCurrentUser();
|
|
568
549
|
if (userResult.data) {
|
|
569
550
|
const profile = userResult.data.profile;
|
|
@@ -575,6 +556,7 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
575
556
|
// You can add more profile fields here as needed
|
|
576
557
|
};
|
|
577
558
|
this.user = userData;
|
|
559
|
+
console.log("[InsforgeManager] loadAuthState() - user loaded:", userData.email);
|
|
578
560
|
if (this.config.onAuthChange) {
|
|
579
561
|
this.config.onAuthChange(userData);
|
|
580
562
|
}
|
|
@@ -582,36 +564,17 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
582
564
|
this.notifyListeners();
|
|
583
565
|
return { success: true };
|
|
584
566
|
} else {
|
|
585
|
-
|
|
586
|
-
if (this.config.onSignOut) {
|
|
587
|
-
try {
|
|
588
|
-
await this.config.onSignOut();
|
|
589
|
-
} catch (error) {
|
|
590
|
-
if (error instanceof Error) {
|
|
591
|
-
console.error("[InsforgeManager] Error clearing cookie:", error.message);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
567
|
+
console.log("[InsforgeManager] loadAuthState() - no user data, error:", userResult.error);
|
|
595
568
|
this.user = null;
|
|
596
569
|
if (this.config.onAuthChange) {
|
|
597
570
|
this.config.onAuthChange(null);
|
|
598
571
|
}
|
|
599
572
|
this.isLoaded = true;
|
|
600
573
|
this.notifyListeners();
|
|
601
|
-
return { success: false, error: "
|
|
574
|
+
return { success: false, error: userResult.error?.message || "no_session" };
|
|
602
575
|
}
|
|
603
576
|
} catch (error) {
|
|
604
|
-
console.error("[InsforgeManager]
|
|
605
|
-
await this.sdk.auth.signOut();
|
|
606
|
-
if (this.config.onSignOut) {
|
|
607
|
-
try {
|
|
608
|
-
await this.config.onSignOut();
|
|
609
|
-
} catch (error2) {
|
|
610
|
-
if (error2 instanceof Error) {
|
|
611
|
-
console.error("[InsforgeManager] Error clearing cookie:", error2.message);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
577
|
+
console.error("[InsforgeManager] loadAuthState() catch error:", error);
|
|
615
578
|
this.user = null;
|
|
616
579
|
if (this.config.onAuthChange) {
|
|
617
580
|
this.config.onAuthChange(null);
|