@djangocfg/api 2.1.149 → 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 +9 -32
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -12
- package/dist/auth.d.ts +1 -12
- package/dist/auth.mjs +9 -32
- package/dist/auth.mjs.map +1 -1
- package/package.json +2 -2
- package/src/auth/context/AuthContext.tsx +12 -40
- package/src/auth/context/types.ts +1 -8
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",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/node": "^24.7.2",
|
|
86
86
|
"@types/react": "^19.0.0",
|
|
87
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
87
|
+
"@djangocfg/typescript-config": "^2.1.151",
|
|
88
88
|
"next": "^16.0.0",
|
|
89
89
|
"react": "^19.0.0",
|
|
90
90
|
"tsup": "^8.5.0",
|
|
@@ -510,48 +510,20 @@ const AuthProviderInternal: React.FC<AuthProviderProps> = ({ children, config })
|
|
|
510
510
|
}
|
|
511
511
|
}, [clearAuthState, accounts]);
|
|
512
512
|
|
|
513
|
-
const logout = useCallback(
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
accounts.logout(); // Clear tokens and profile
|
|
521
|
-
setInitialized(true);
|
|
522
|
-
setIsLoading(false);
|
|
523
|
-
|
|
524
|
-
// Use hardReplace for full page reload + replace history
|
|
525
|
-
// This ensures contexts reinitialize AND back button won't return to protected page
|
|
526
|
-
const authCallbackUrl = config?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
|
|
527
|
-
router.hardReplace(authCallbackUrl);
|
|
528
|
-
};
|
|
513
|
+
const logout = useCallback((): void => {
|
|
514
|
+
// Track logout
|
|
515
|
+
Analytics.event(AnalyticsEvent.AUTH_LOGOUT, {
|
|
516
|
+
category: AnalyticsCategory.AUTH,
|
|
517
|
+
});
|
|
529
518
|
|
|
530
|
-
//
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
519
|
+
accounts.logout(); // Clear tokens and profile
|
|
520
|
+
setInitialized(true);
|
|
521
|
+
setIsLoading(false);
|
|
535
522
|
|
|
536
|
-
// Use
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
description: 'Are you sure you want to logout?',
|
|
541
|
-
confirmationButtonText: 'Logout',
|
|
542
|
-
cancellationButtonText: 'Cancel',
|
|
543
|
-
color: 'error',
|
|
544
|
-
});
|
|
545
|
-
if (confirmed) {
|
|
546
|
-
performLogout();
|
|
547
|
-
}
|
|
548
|
-
} else {
|
|
549
|
-
// Fallback to browser confirm
|
|
550
|
-
const confirmed = window.confirm('Are you sure you want to logout?');
|
|
551
|
-
if (confirmed) {
|
|
552
|
-
performLogout();
|
|
553
|
-
}
|
|
554
|
-
}
|
|
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);
|
|
555
527
|
}, [accounts, config?.routes?.defaultAuthCallback, router]);
|
|
556
528
|
|
|
557
529
|
// Computed: Is admin user (staff or superuser)
|
|
@@ -14,13 +14,6 @@ export interface AuthConfig {
|
|
|
14
14
|
defaultAuthCallback?: string;
|
|
15
15
|
};
|
|
16
16
|
onLogout?: () => void;
|
|
17
|
-
onConfirm?: (options: {
|
|
18
|
-
title: string;
|
|
19
|
-
description: string;
|
|
20
|
-
confirmationButtonText: string;
|
|
21
|
-
cancellationButtonText: string;
|
|
22
|
-
color: string;
|
|
23
|
-
}) => Promise<{ confirmed: boolean }>;
|
|
24
17
|
}
|
|
25
18
|
|
|
26
19
|
// Auth context interface
|
|
@@ -57,7 +50,7 @@ export interface AuthContextType {
|
|
|
57
50
|
should_prompt_2fa?: boolean;
|
|
58
51
|
}>;
|
|
59
52
|
refreshToken: () => Promise<{ success: boolean; message: string }>;
|
|
60
|
-
logout: (
|
|
53
|
+
logout: () => void;
|
|
61
54
|
|
|
62
55
|
// Redirect URL Methods - for saving URL before auth redirect
|
|
63
56
|
saveRedirectUrl: (url: string) => void;
|