@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/components.cjs.map +1 -1
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +11 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -565,7 +565,16 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
565
565
|
// Called after hydration to get complete user information beyond what's in cookies
|
|
566
566
|
async loadAuthState() {
|
|
567
567
|
try {
|
|
568
|
-
|
|
568
|
+
const { isLoggedIn } = await this.sdk.auth.restoreSession();
|
|
569
|
+
if (!isLoggedIn) {
|
|
570
|
+
this.user = null;
|
|
571
|
+
if (this.config.onAuthChange) {
|
|
572
|
+
this.config.onAuthChange(null);
|
|
573
|
+
}
|
|
574
|
+
this.isLoaded = true;
|
|
575
|
+
this.notifyListeners();
|
|
576
|
+
return { success: false, error: "no_session" };
|
|
577
|
+
}
|
|
569
578
|
const userResult = await this.sdk.auth.getCurrentUser();
|
|
570
579
|
if (userResult.data) {
|
|
571
580
|
const profile = userResult.data.profile;
|
|
@@ -577,7 +586,6 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
577
586
|
// You can add more profile fields here as needed
|
|
578
587
|
};
|
|
579
588
|
this.user = userData;
|
|
580
|
-
console.log("[InsforgeManager] loadAuthState() - user loaded:", userData.email);
|
|
581
589
|
if (this.config.onAuthChange) {
|
|
582
590
|
this.config.onAuthChange(userData);
|
|
583
591
|
}
|
|
@@ -585,17 +593,15 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
585
593
|
this.notifyListeners();
|
|
586
594
|
return { success: true };
|
|
587
595
|
} else {
|
|
588
|
-
console.log("[InsforgeManager] loadAuthState() - no user data, error:", userResult.error);
|
|
589
596
|
this.user = null;
|
|
590
597
|
if (this.config.onAuthChange) {
|
|
591
598
|
this.config.onAuthChange(null);
|
|
592
599
|
}
|
|
593
600
|
this.isLoaded = true;
|
|
594
601
|
this.notifyListeners();
|
|
595
|
-
return { success: false, error: userResult.error?.message || "
|
|
602
|
+
return { success: false, error: userResult.error?.message || "failed_to_get_user" };
|
|
596
603
|
}
|
|
597
604
|
} catch (error) {
|
|
598
|
-
console.error("[InsforgeManager] loadAuthState() catch error:", error);
|
|
599
605
|
this.user = null;
|
|
600
606
|
if (this.config.onAuthChange) {
|
|
601
607
|
this.config.onAuthChange(null);
|