fix: Mobile login redirects to homepage without showing Auth0 login page (#188) #193

Merged
egullickson merged 9 commits from issue-188-fix-mobile-login-redirect into main 2026-02-15 15:36:38 +00:00
Showing only changes of commit 850f713310 - Show all commits

View File

@@ -365,17 +365,24 @@ function App() {
const [showAddVehicle, setShowAddVehicle] = useState(false);
// 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(() => {
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) {
navigateToScreen(screen, { source: 'url-sync' });
}
}, []); // 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)
// Skip on auth routes -- replaceState would strip ?code= and &state= params that
// Auth0 SDK needs for handleRedirectCallback (child effects fire before parent effects)
useEffect(() => {
const path = window.location.pathname;
if (path === '/callback' || path === '/signup' || path === '/verify-email') return;
const targetPath = screenToRoute[activeScreen];
if (targetPath && window.location.pathname !== targetPath) {
if (targetPath && path !== targetPath) {
window.history.replaceState(null, '', targetPath);
}
}, [activeScreen]);