fix: Mobile login redirects to homepage without showing Auth0 login page (#188) #193
@@ -496,6 +496,16 @@ function App() {
|
|||||||
const isAuthRoute = isSignupRoute || isVerifyEmailRoute || isOnboardingRoute;
|
const isAuthRoute = isSignupRoute || isVerifyEmailRoute || isOnboardingRoute;
|
||||||
const shouldShowHomePage = !isGarageRoute && !isCallbackRoute && !isAuthRoute;
|
const shouldShowHomePage = !isGarageRoute && !isCallbackRoute && !isAuthRoute;
|
||||||
|
|
||||||
|
const [callbackTimedOut, setCallbackTimedOut] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (isCallbackRoute && !isAuthenticated && !isLoading) {
|
||||||
|
const timer = setTimeout(() => setCallbackTimedOut(true), 10000);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}
|
||||||
|
setCallbackTimedOut(false);
|
||||||
|
return undefined;
|
||||||
|
}, [isCallbackRoute, isAuthenticated, isLoading]);
|
||||||
|
|
||||||
// Enhanced navigation handlers for mobile
|
// Enhanced navigation handlers for mobile
|
||||||
const handleVehicleSelect = useCallback((vehicle: Vehicle) => {
|
const handleVehicleSelect = useCallback((vehicle: Vehicle) => {
|
||||||
setSelectedVehicle(vehicle);
|
setSelectedVehicle(vehicle);
|
||||||
@@ -572,6 +582,9 @@ function App() {
|
|||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (callbackTimedOut) {
|
||||||
|
return <Navigate to="/" replace />;
|
||||||
|
}
|
||||||
if (mobileMode) {
|
if (mobileMode) {
|
||||||
return (
|
return (
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
|
|||||||
@@ -71,25 +71,27 @@ class IndexedDBStorage implements StorageAdapter, Auth0Cache {
|
|||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const transaction = this.db!.transaction([this.storeName], 'readonly');
|
const transaction = this.db!.transaction([this.storeName], 'readonly');
|
||||||
const store = transaction.objectStore(this.storeName);
|
const store = transaction.objectStore(this.storeName);
|
||||||
const request = store.getAll();
|
const request = store.openCursor();
|
||||||
|
|
||||||
request.onsuccess = () => {
|
|
||||||
const results = request.result;
|
|
||||||
this.memoryCache.clear();
|
this.memoryCache.clear();
|
||||||
|
|
||||||
for (const item of results) {
|
request.onsuccess = () => {
|
||||||
if (item.key && typeof item.value === 'string') {
|
const cursor = request.result;
|
||||||
this.memoryCache.set(item.key, item.value);
|
if (cursor) {
|
||||||
|
const key = cursor.key as string;
|
||||||
|
const value = cursor.value;
|
||||||
|
if (typeof key === 'string' && typeof value === 'string') {
|
||||||
|
this.memoryCache.set(key, value);
|
||||||
}
|
}
|
||||||
}
|
cursor.continue();
|
||||||
|
} else {
|
||||||
console.log(`[IndexedDB] Loaded ${this.memoryCache.size} items into cache`);
|
console.log(`[IndexedDB] Loaded ${this.memoryCache.size} items into cache`);
|
||||||
resolve();
|
resolve();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
request.onerror = () => {
|
request.onerror = () => {
|
||||||
console.warn('[IndexedDB] Failed to load cache from DB:', request.error);
|
console.warn('[IndexedDB] Failed to load cache from DB:', request.error);
|
||||||
resolve(); // Don't fail initialization
|
resolve();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -199,12 +201,15 @@ class IndexedDBStorage implements StorageAdapter, Auth0Cache {
|
|||||||
|
|
||||||
async set(key: string, value: any): Promise<void> {
|
async set(key: string, value: any): Promise<void> {
|
||||||
await this.initPromise;
|
await this.initPromise;
|
||||||
this.setItem(key, JSON.stringify(value));
|
const stringValue = JSON.stringify(value);
|
||||||
|
this.memoryCache.set(key, stringValue);
|
||||||
|
await this.persistToDB(key, stringValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(key: string): Promise<void> {
|
async remove(key: string): Promise<void> {
|
||||||
await this.initPromise;
|
await this.initPromise;
|
||||||
this.removeItem(key);
|
this.memoryCache.delete(key);
|
||||||
|
await this.persistToDB(key, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additional methods for enhanced functionality
|
// Additional methods for enhanced functionality
|
||||||
|
|||||||
Reference in New Issue
Block a user