fix: Mobile login redirects to homepage without showing Auth0 login page (#188) #193
@@ -365,17 +365,24 @@ function App() {
|
|||||||
const [showAddVehicle, setShowAddVehicle] = useState(false);
|
const [showAddVehicle, setShowAddVehicle] = useState(false);
|
||||||
|
|
||||||
// Sync browser URL to Zustand screen state on mount (enables direct URL navigation on mobile)
|
// Sync browser URL to Zustand screen state on mount (enables direct URL navigation on mobile)
|
||||||
|
// Skip on auth routes -- their query params must survive until Auth0 SDK processes them
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const screen = routeToScreen[window.location.pathname];
|
const path = window.location.pathname;
|
||||||
|
if (path === '/callback' || path === '/signup' || path === '/verify-email') return;
|
||||||
|
const screen = routeToScreen[path];
|
||||||
if (screen && screen !== activeScreen) {
|
if (screen && screen !== activeScreen) {
|
||||||
navigateToScreen(screen, { source: 'url-sync' });
|
navigateToScreen(screen, { source: 'url-sync' });
|
||||||
}
|
}
|
||||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps -- intentionally runs once on mount
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps -- intentionally runs once on mount
|
||||||
|
|
||||||
// Sync Zustand screen changes back to browser URL (enables bookmarks and URL sharing)
|
// Sync Zustand screen changes back to browser URL (enables bookmarks and URL sharing)
|
||||||
|
// Skip on auth routes -- replaceState would strip ?code= and &state= params that
|
||||||
|
// Auth0 SDK needs for handleRedirectCallback (child effects fire before parent effects)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const path = window.location.pathname;
|
||||||
|
if (path === '/callback' || path === '/signup' || path === '/verify-email') return;
|
||||||
const targetPath = screenToRoute[activeScreen];
|
const targetPath = screenToRoute[activeScreen];
|
||||||
if (targetPath && window.location.pathname !== targetPath) {
|
if (targetPath && path !== targetPath) {
|
||||||
window.history.replaceState(null, '', targetPath);
|
window.history.replaceState(null, '', targetPath);
|
||||||
}
|
}
|
||||||
}, [activeScreen]);
|
}, [activeScreen]);
|
||||||
|
|||||||
Reference in New Issue
Block a user