@insforge/react 0.2.4 → 0.2.5
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.js +26 -3
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +26 -3
- package/dist/components.mjs.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +91 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -3
- package/dist/index.mjs.map +1 -1
- package/dist/router.js +26 -3
- package/dist/router.js.map +1 -1
- package/dist/router.mjs +26 -3
- package/dist/router.mjs.map +1 -1
- package/package.json +2 -2
package/dist/components.mjs
CHANGED
|
@@ -1407,7 +1407,7 @@ function InsforgeCallback({
|
|
|
1407
1407
|
onRedirect
|
|
1408
1408
|
}) {
|
|
1409
1409
|
const isProcessingRef = useRef(false);
|
|
1410
|
-
const {
|
|
1410
|
+
const { handleAuthCallback } = useInsforge();
|
|
1411
1411
|
useEffect(() => {
|
|
1412
1412
|
const processCallback = async () => {
|
|
1413
1413
|
if (isProcessingRef.current) return;
|
|
@@ -1427,7 +1427,30 @@ function InsforgeCallback({
|
|
|
1427
1427
|
}
|
|
1428
1428
|
return;
|
|
1429
1429
|
}
|
|
1430
|
-
const
|
|
1430
|
+
const accessToken = searchParams.get("access_token") || searchParams.get("auth_token");
|
|
1431
|
+
const userId = searchParams.get("user_id");
|
|
1432
|
+
const email = searchParams.get("email");
|
|
1433
|
+
const name = searchParams.get("name");
|
|
1434
|
+
if (!accessToken) {
|
|
1435
|
+
const errorMsg = "no_token";
|
|
1436
|
+
if (onError) {
|
|
1437
|
+
onError(errorMsg);
|
|
1438
|
+
} else {
|
|
1439
|
+
const errorUrl = "/?error=" + encodeURIComponent(errorMsg);
|
|
1440
|
+
if (onRedirect) {
|
|
1441
|
+
onRedirect(errorUrl);
|
|
1442
|
+
} else {
|
|
1443
|
+
window.location.href = errorUrl;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
const result = await handleAuthCallback({
|
|
1449
|
+
accessToken,
|
|
1450
|
+
userId: userId || void 0,
|
|
1451
|
+
email: email || void 0,
|
|
1452
|
+
name: name || void 0
|
|
1453
|
+
});
|
|
1431
1454
|
if (!result.success) {
|
|
1432
1455
|
const errorMsg = result.error || "authentication_failed";
|
|
1433
1456
|
if (onError) {
|
|
@@ -1456,7 +1479,7 @@ function InsforgeCallback({
|
|
|
1456
1479
|
}
|
|
1457
1480
|
};
|
|
1458
1481
|
processCallback();
|
|
1459
|
-
}, []);
|
|
1482
|
+
}, [handleAuthCallback, redirectTo, onSuccess, onError, onRedirect]);
|
|
1460
1483
|
const defaultLoading = /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
1461
1484
|
/* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold mb-4", children: "Completing authentication..." }),
|
|
1462
1485
|
/* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto" })
|