@object-ui/auth 11.4.0 → 11.5.0
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/CHANGELOG.md +8 -0
- package/dist/AuthProvider.d.ts.map +1 -1
- package/dist/AuthProvider.js +17 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../src/AuthProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAwB,kBAAkB,EAAE,kBAAkB,EAAyG,MAAM,SAAS,CAAC;AAKnM,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,MAAM,EAAE,cAAc,EACtB,iBAAiB,EACjB,OAAc,EACd,WAAW,EACX,QAAQ,GACT,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../src/AuthProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAwB,kBAAkB,EAAE,kBAAkB,EAAyG,MAAM,SAAS,CAAC;AAKnM,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,MAAM,EAAE,cAAc,EACtB,iBAAiB,EACjB,OAAc,EACd,WAAW,EACX,QAAQ,GACT,EAAE,iBAAiB,qBAsiBnB"}
|
package/dist/AuthProvider.js
CHANGED
|
@@ -275,18 +275,20 @@ export function AuthProvider({ authUrl, client: externalClient, onAuthStateChang
|
|
|
275
275
|
}
|
|
276
276
|
}, [client]);
|
|
277
277
|
// --- Organization methods ---
|
|
278
|
-
const refreshOrganizations = useCallback(async () => {
|
|
278
|
+
const refreshOrganizations = useCallback(async (isCancelled) => {
|
|
279
279
|
if (!enabled || isPreviewMode)
|
|
280
280
|
return;
|
|
281
281
|
setIsOrganizationsLoading(true);
|
|
282
282
|
try {
|
|
283
283
|
const orgs = await client.listOrganizations();
|
|
284
|
+
if (isCancelled?.())
|
|
285
|
+
return;
|
|
284
286
|
setOrganizations(orgs);
|
|
285
287
|
// If no active org is set but orgs exist, try to get active from server
|
|
286
288
|
if (orgs.length > 0 && !activeOrganization) {
|
|
287
289
|
try {
|
|
288
290
|
const active = await client.getActiveOrganization();
|
|
289
|
-
if (active) {
|
|
291
|
+
if (active && !isCancelled?.()) {
|
|
290
292
|
setActiveOrganization(active);
|
|
291
293
|
ActiveOrganizationStorage.set(active.id);
|
|
292
294
|
}
|
|
@@ -297,10 +299,16 @@ export function AuthProvider({ authUrl, client: externalClient, onAuthStateChang
|
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
301
|
catch (err) {
|
|
300
|
-
|
|
302
|
+
// A route change / unmount racing the in-flight request is not a real
|
|
303
|
+
// failure — only warn when this call is still the one that matters.
|
|
304
|
+
if (!isCancelled?.()) {
|
|
305
|
+
console.warn('[AuthProvider] Failed to load organizations:', err);
|
|
306
|
+
}
|
|
301
307
|
}
|
|
302
308
|
finally {
|
|
303
|
-
|
|
309
|
+
if (!isCancelled?.()) {
|
|
310
|
+
setIsOrganizationsLoading(false);
|
|
311
|
+
}
|
|
304
312
|
}
|
|
305
313
|
}, [client, enabled, isPreviewMode, activeOrganization]);
|
|
306
314
|
// Refresh the active member row whenever the active org changes. Used by
|
|
@@ -335,9 +343,11 @@ export function AuthProvider({ authUrl, client: externalClient, onAuthStateChang
|
|
|
335
343
|
}, [refreshActiveMember]);
|
|
336
344
|
// Load organizations once user is authenticated
|
|
337
345
|
useEffect(() => {
|
|
338
|
-
if (user && enabled && !isPreviewMode)
|
|
339
|
-
|
|
340
|
-
|
|
346
|
+
if (!(user && enabled && !isPreviewMode))
|
|
347
|
+
return;
|
|
348
|
+
let cancelled = false;
|
|
349
|
+
refreshOrganizations(() => cancelled);
|
|
350
|
+
return () => { cancelled = true; };
|
|
341
351
|
}, [user, enabled, isPreviewMode]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
342
352
|
const switchOrganization = useCallback(async (orgId) => {
|
|
343
353
|
setError(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/auth",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Authentication system for Object UI with AuthProvider, useAuth hook, AuthGuard, and form components.",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"better-auth": "^1.6.22",
|
|
34
|
-
"@object-ui/types": "11.
|
|
34
|
+
"@object-ui/types": "11.5.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react": "19.2.17",
|