@insforge/sdk 1.1.2-edge.1 → 1.1.2-edge.2
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 +19 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -613,23 +613,23 @@ var Auth = class {
|
|
|
613
613
|
return { data: { session: null }, error: null };
|
|
614
614
|
}
|
|
615
615
|
try {
|
|
616
|
-
const
|
|
617
|
-
if (
|
|
618
|
-
this.http.setAuthToken(
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
616
|
+
const existingSession = this.tokenManager.getSession();
|
|
617
|
+
if (existingSession) {
|
|
618
|
+
this.http.setAuthToken(existingSession.accessToken);
|
|
619
|
+
return { data: { session: existingSession }, error: null };
|
|
620
|
+
}
|
|
621
|
+
const accessToken = this.tokenManager.getAccessToken();
|
|
622
|
+
if (accessToken) {
|
|
623
|
+
this.http.setAuthToken(accessToken);
|
|
624
|
+
try {
|
|
625
|
+
const response = await this.http.get("/api/auth/sessions/current");
|
|
626
|
+
const session = { accessToken, user: response.user };
|
|
627
|
+
this.tokenManager.saveSession(session);
|
|
628
|
+
return { data: { session }, error: null };
|
|
629
|
+
} catch (error) {
|
|
630
|
+
this.tokenManager.clearSession();
|
|
631
|
+
this.http.setAuthToken(null);
|
|
631
632
|
}
|
|
632
|
-
return { data: { session }, error: null };
|
|
633
633
|
}
|
|
634
634
|
if (typeof window !== "undefined") {
|
|
635
635
|
try {
|
|
@@ -661,9 +661,9 @@ var Auth = class {
|
|
|
661
661
|
if (error instanceof InsForgeError) {
|
|
662
662
|
if (error.statusCode === 404) {
|
|
663
663
|
this.tokenManager.setStorageMode();
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
return { data: { session
|
|
664
|
+
const session = this.tokenManager.getSession();
|
|
665
|
+
if (session) {
|
|
666
|
+
return { data: { session }, error: null };
|
|
667
667
|
}
|
|
668
668
|
return { data: { session: null }, error: null };
|
|
669
669
|
}
|