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