Auto-redirect to login on 401 API responses
When a session token expires, API calls return 401 but nothing caught it — errors were shown as generic dialogs or swallowed. Now both apiClient and streamingService detect 401 responses and clear auth state, which causes App.tsx to render the login modal automatically.
This commit is contained in:
parent
3acf8db7af
commit
a1829957c1
4 changed files with 29 additions and 1 deletions
|
|
@ -18,6 +18,8 @@ import { Button } from './components/ui/button';
|
|||
import { Filter } from 'lucide-react';
|
||||
import type { GeoJSONFeatureCollection, PropertyProperties, PropertyFeature, POI, POITravelFilter } from '@/types';
|
||||
import { refreshListings, streamListingGeoJSON, fetchUserPOIs, type StreamingProgress } from '@/services';
|
||||
import { setOnUnauthorized } from '@/services/apiClient';
|
||||
import { clearPasskeyUser } from './auth/passkeyService';
|
||||
import { poiMetricPropertyName, injectPoiMetricProperty } from '@/utils/poiUtils';
|
||||
import { useTaskProgress } from '@/hooks/useTaskProgress';
|
||||
|
||||
|
|
@ -94,6 +96,13 @@ function App() {
|
|||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setOnUnauthorized(() => {
|
||||
clearPasskeyUser();
|
||||
setUser(null);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handlePasskeyLogin = (passkeyUser: AuthUser) => {
|
||||
setUser(passkeyUser);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue