@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/api",
3
- "version": "2.1.149",
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.149",
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(async (options?: { skipConfirm?: boolean }): Promise<void> => {
514
- const performLogout = () => {
515
- // Track logout
516
- Analytics.event(AnalyticsEvent.AUTH_LOGOUT, {
517
- category: AnalyticsCategory.AUTH,
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
- // Skip confirmation if requested (e.g., after account deletion)
531
- if (options?.skipConfirm) {
532
- performLogout();
533
- return;
534
- }
519
+ accounts.logout(); // Clear tokens and profile
520
+ setInitialized(true);
521
+ setIsLoading(false);
535
522
 
536
- // Use config.onConfirm if provided, otherwise use a simple confirm
537
- if (configRef.current?.onConfirm) {
538
- const { confirmed } = await configRef.current.onConfirm({
539
- title: 'Logout',
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: (options?: { skipConfirm?: boolean }) => Promise<void>;
53
+ logout: () => void;
61
54
 
62
55
  // Redirect URL Methods - for saving URL before auth redirect
63
56
  saveRedirectUrl: (url: string) => void;