d594d00227
- Fixed theme not being reflected on gallery and admin login pages - Created GlobalThemeProvider to apply themes globally - Updated gallery and admin login pages to use dynamic CSS variables - Added complete translations for all admin sections in English and German: - Notifications management - Event view and creation - Photo upload functionality - Category management - Archive page view - Analytics dashboard - Branding and theme settings - System settings - CMS page management - Email configuration - Fixed admin photo management display issues - Fixed photo upload category assignment - Added password reset functionality for galleries - Improved error handling and user feedback 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { useEffect, useCallback } from 'react';
|
|
import { useAdminAuth } from '../contexts';
|
|
import { api } from '../config/api';
|
|
|
|
// Hook to handle session timeout
|
|
export const useSessionTimeout = () => {
|
|
const { logout } = useAdminAuth();
|
|
|
|
const handleSessionTimeout = useCallback((error: any) => {
|
|
if (error?.response?.data?.code === 'SESSION_TIMEOUT') {
|
|
// Clear local auth state
|
|
logout();
|
|
// Redirect to login with message
|
|
window.location.href = '/admin/login?session=expired';
|
|
return true;
|
|
}
|
|
return false;
|
|
}, [logout]);
|
|
|
|
useEffect(() => {
|
|
// Add response interceptor to handle session timeout
|
|
const interceptor = api.interceptors.response.use(
|
|
response => response,
|
|
error => {
|
|
if (handleSessionTimeout(error)) {
|
|
// Don't propagate the error if it was a session timeout
|
|
return Promise.reject(new Error('Session expired'));
|
|
}
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
// Clean up interceptor on unmount
|
|
return () => {
|
|
api.interceptors.response.eject(interceptor);
|
|
};
|
|
}, [handleSessionTimeout]);
|
|
|
|
return { handleSessionTimeout };
|
|
}; |