@insforge/react 0.2.9 → 0.2.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/components.d.mts +7 -2
- package/dist/components.d.ts +7 -2
- package/dist/components.js +10 -30
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +10 -30
- package/dist/components.mjs.map +1 -1
- package/dist/index.js +10 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/components.mjs
CHANGED
|
@@ -1384,18 +1384,19 @@ function SignedOut({ children }) {
|
|
|
1384
1384
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1385
1385
|
}
|
|
1386
1386
|
function InsforgeCallback({
|
|
1387
|
-
redirectTo,
|
|
1387
|
+
redirectTo = "/",
|
|
1388
1388
|
onSuccess,
|
|
1389
1389
|
onError,
|
|
1390
1390
|
loadingComponent,
|
|
1391
1391
|
onRedirect
|
|
1392
1392
|
}) {
|
|
1393
1393
|
const isProcessingRef = useRef(false);
|
|
1394
|
-
const {
|
|
1394
|
+
const { isLoaded, isSignedIn } = useInsforge();
|
|
1395
1395
|
useEffect(() => {
|
|
1396
|
+
if (!isLoaded) return;
|
|
1397
|
+
if (isProcessingRef.current) return;
|
|
1398
|
+
isProcessingRef.current = true;
|
|
1396
1399
|
const processCallback = async () => {
|
|
1397
|
-
if (isProcessingRef.current) return;
|
|
1398
|
-
isProcessingRef.current = true;
|
|
1399
1400
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1400
1401
|
const error = searchParams.get("error");
|
|
1401
1402
|
if (error) {
|
|
@@ -1411,26 +1412,8 @@ function InsforgeCallback({
|
|
|
1411
1412
|
}
|
|
1412
1413
|
return;
|
|
1413
1414
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
const errorMsg = "no_token";
|
|
1417
|
-
if (onError) {
|
|
1418
|
-
onError(errorMsg);
|
|
1419
|
-
} else {
|
|
1420
|
-
const errorUrl = "/?error=" + encodeURIComponent(errorMsg);
|
|
1421
|
-
if (onRedirect) {
|
|
1422
|
-
onRedirect(errorUrl);
|
|
1423
|
-
} else {
|
|
1424
|
-
window.location.href = errorUrl;
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
return;
|
|
1428
|
-
}
|
|
1429
|
-
const result = await handleAuthCallback({
|
|
1430
|
-
accessToken
|
|
1431
|
-
});
|
|
1432
|
-
if (!result.success) {
|
|
1433
|
-
const errorMsg = result.error || "authentication_failed";
|
|
1415
|
+
if (!isSignedIn) {
|
|
1416
|
+
const errorMsg = "authentication_failed";
|
|
1434
1417
|
if (onError) {
|
|
1435
1418
|
onError(errorMsg);
|
|
1436
1419
|
} else {
|
|
@@ -1447,17 +1430,14 @@ function InsforgeCallback({
|
|
|
1447
1430
|
if (onSuccess) {
|
|
1448
1431
|
onSuccess();
|
|
1449
1432
|
}
|
|
1450
|
-
const destination = redirectTo || sessionStorage.getItem("auth_destination") || sessionStorage.getItem("oauth_final_destination") || "/";
|
|
1451
|
-
sessionStorage.removeItem("auth_destination");
|
|
1452
|
-
sessionStorage.removeItem("oauth_final_destination");
|
|
1453
1433
|
if (onRedirect) {
|
|
1454
|
-
onRedirect(
|
|
1434
|
+
onRedirect(redirectTo);
|
|
1455
1435
|
} else {
|
|
1456
|
-
window.location.href =
|
|
1436
|
+
window.location.href = redirectTo;
|
|
1457
1437
|
}
|
|
1458
1438
|
};
|
|
1459
1439
|
processCallback();
|
|
1460
|
-
}, [
|
|
1440
|
+
}, [isLoaded, isSignedIn, redirectTo, onSuccess, onError, onRedirect]);
|
|
1461
1441
|
const defaultLoading = /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
1462
1442
|
/* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold mb-4", children: "Completing authentication..." }),
|
|
1463
1443
|
/* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto" })
|