antaeus.keycloak.react 2.2.1 → 2.2.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 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1351,7 +1351,6 @@ var DeviceLogin = ({
|
|
|
1351
1351
|
const [loading, setLoading] = useState(true);
|
|
1352
1352
|
const [timeRemaining, setTimeRemaining] = useState(null);
|
|
1353
1353
|
const pollTimerRef = useRef(null);
|
|
1354
|
-
const userManagerRef = useRef(null);
|
|
1355
1354
|
useEffect(() => {
|
|
1356
1355
|
const initDeviceFlow = async () => {
|
|
1357
1356
|
setLoading(true);
|
|
@@ -1386,16 +1385,6 @@ var DeviceLogin = ({
|
|
|
1386
1385
|
}, [deviceData, timeRemaining]);
|
|
1387
1386
|
useEffect(() => {
|
|
1388
1387
|
if (!deviceData) return;
|
|
1389
|
-
userManagerRef.current = auth.userManager;
|
|
1390
|
-
if (userManagerRef.current) {
|
|
1391
|
-
const settings = userManagerRef.current.settings;
|
|
1392
|
-
console.log("[DeviceLogin] UserManager storage configured:", {
|
|
1393
|
-
hasUserStore: !!settings.userStore,
|
|
1394
|
-
storeType: settings.userStore ? "configured" : "default"
|
|
1395
|
-
});
|
|
1396
|
-
} else {
|
|
1397
|
-
console.error("[DeviceLogin] UserManager is not available in auth context");
|
|
1398
|
-
}
|
|
1399
1388
|
const poll = async () => {
|
|
1400
1389
|
try {
|
|
1401
1390
|
const tokenResponse = await pollForToken(apiBaseUrl, deviceData.device_code);
|
|
@@ -1415,32 +1404,26 @@ var DeviceLogin = ({
|
|
|
1415
1404
|
session_state: null
|
|
1416
1405
|
// Device flow doesn't have session_state
|
|
1417
1406
|
});
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
if (events && events._userLoaded) {
|
|
1437
|
-
events._userLoaded.raise(user);
|
|
1438
|
-
console.log("[DeviceLogin] Triggered user loaded event");
|
|
1439
|
-
}
|
|
1440
|
-
} else {
|
|
1441
|
-
console.error("[DeviceLogin] UserManager not available, cannot store user");
|
|
1442
|
-
throw new Error("UserManager not available. Cannot complete login.");
|
|
1407
|
+
console.log("[DeviceLogin] Device flow authentication successful", {
|
|
1408
|
+
hasAccessToken: !!user.access_token,
|
|
1409
|
+
hasRefreshToken: !!user.refresh_token,
|
|
1410
|
+
expiresAt: user.expires_at,
|
|
1411
|
+
profile: userInfo.preferred_username
|
|
1412
|
+
});
|
|
1413
|
+
const storageKey = `oidc.user:${auth.settings.authority}:${auth.settings.client_id}`;
|
|
1414
|
+
const userJson = user.toStorageString();
|
|
1415
|
+
const storage = auth.settings.userStore?.store || window.sessionStorage;
|
|
1416
|
+
console.log("[DeviceLogin] Storing user in storage...", {
|
|
1417
|
+
storageKey,
|
|
1418
|
+
storageType: storage === window.localStorage ? "localStorage" : "sessionStorage"
|
|
1419
|
+
});
|
|
1420
|
+
storage.setItem(storageKey, userJson);
|
|
1421
|
+
const stored = storage.getItem(storageKey);
|
|
1422
|
+
if (!stored) {
|
|
1423
|
+
console.error("[DeviceLogin] Failed to store user in storage!");
|
|
1424
|
+
throw new Error("Failed to store user session. Please try again.");
|
|
1443
1425
|
}
|
|
1426
|
+
console.log("[DeviceLogin] User stored successfully in", storage === window.localStorage ? "localStorage" : "sessionStorage");
|
|
1444
1427
|
if (onSuccess) {
|
|
1445
1428
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1446
1429
|
onSuccess(user);
|