@djangocfg/api 2.1.150 → 2.1.151
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/auth.cjs +8 -27
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -3
- package/dist/auth.d.ts +1 -3
- package/dist/auth.mjs +8 -27
- package/dist/auth.mjs.map +1 -1
- package/package.json +2 -3
- package/src/auth/context/AuthContext.tsx +12 -33
- package/src/auth/context/types.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/api",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.151",
|
|
4
4
|
"description": "Auto-generated TypeScript API client with React hooks, SWR integration, and Zod validation for Django REST Framework backends",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"django",
|
|
@@ -74,7 +74,6 @@
|
|
|
74
74
|
"check": "tsc --noEmit"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@djangocfg/i18n": "^2.1.150",
|
|
78
77
|
"consola": "^3.4.2",
|
|
79
78
|
"next": ">=16.0.0",
|
|
80
79
|
"p-retry": "^7.0.0",
|
|
@@ -85,7 +84,7 @@
|
|
|
85
84
|
"devDependencies": {
|
|
86
85
|
"@types/node": "^24.7.2",
|
|
87
86
|
"@types/react": "^19.0.0",
|
|
88
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
87
|
+
"@djangocfg/typescript-config": "^2.1.151",
|
|
89
88
|
"next": "^16.0.0",
|
|
90
89
|
"react": "^19.0.0",
|
|
91
90
|
"tsup": "^8.5.0",
|
|
@@ -8,7 +8,6 @@ import React, {
|
|
|
8
8
|
|
|
9
9
|
import { useCfgRouter, useLocalStorage, useQueryParams } from '../hooks';
|
|
10
10
|
|
|
11
|
-
import { getT } from '@djangocfg/i18n';
|
|
12
11
|
import { api as apiAccounts, Enums } from '../../';
|
|
13
12
|
import { clearProfileCache, getCachedProfile } from '../hooks/useProfileCache';
|
|
14
13
|
import { useAuthRedirectManager } from '../hooks/useAuthRedirect';
|
|
@@ -511,40 +510,20 @@ const AuthProviderInternal: React.FC<AuthProviderProps> = ({ children, config })
|
|
|
511
510
|
}
|
|
512
511
|
}, [clearAuthState, accounts]);
|
|
513
512
|
|
|
514
|
-
const logout = useCallback(
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
accounts.logout(); // Clear tokens and profile
|
|
522
|
-
setInitialized(true);
|
|
523
|
-
setIsLoading(false);
|
|
524
|
-
|
|
525
|
-
// Use hardReplace for full page reload + replace history
|
|
526
|
-
// This ensures contexts reinitialize AND back button won't return to protected page
|
|
527
|
-
const authCallbackUrl = config?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
|
|
528
|
-
router.hardReplace(authCallbackUrl);
|
|
529
|
-
};
|
|
513
|
+
const logout = useCallback((): void => {
|
|
514
|
+
// Track logout
|
|
515
|
+
Analytics.event(AnalyticsEvent.AUTH_LOGOUT, {
|
|
516
|
+
category: AnalyticsCategory.AUTH,
|
|
517
|
+
});
|
|
530
518
|
|
|
531
|
-
//
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
519
|
+
accounts.logout(); // Clear tokens and profile
|
|
520
|
+
setInitialized(true);
|
|
521
|
+
setIsLoading(false);
|
|
536
522
|
|
|
537
|
-
// Use
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
confirmText: getT('layouts.logout.confirm'),
|
|
542
|
-
cancelText: getT('layouts.logout.cancel'),
|
|
543
|
-
variant: 'destructive',
|
|
544
|
-
});
|
|
545
|
-
if (confirmed) {
|
|
546
|
-
performLogout();
|
|
547
|
-
}
|
|
523
|
+
// Use hardReplace for full page reload + replace history
|
|
524
|
+
// This ensures contexts reinitialize AND back button won't return to protected page
|
|
525
|
+
const authCallbackUrl = config?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
|
|
526
|
+
router.hardReplace(authCallbackUrl);
|
|
548
527
|
}, [accounts, config?.routes?.defaultAuthCallback, router]);
|
|
549
528
|
|
|
550
529
|
// Computed: Is admin user (staff or superuser)
|
|
@@ -50,7 +50,7 @@ export interface AuthContextType {
|
|
|
50
50
|
should_prompt_2fa?: boolean;
|
|
51
51
|
}>;
|
|
52
52
|
refreshToken: () => Promise<{ success: boolean; message: string }>;
|
|
53
|
-
logout: (
|
|
53
|
+
logout: () => void;
|
|
54
54
|
|
|
55
55
|
// Redirect URL Methods - for saving URL before auth redirect
|
|
56
56
|
saveRedirectUrl: (url: string) => void;
|