Reverted to commit 06ed528d76

This commit is contained in:
gpt-engineer-app[bot]
2025-10-11 15:58:56 +00:00
parent 1df9ada8ae
commit f37b99a5f9
33 changed files with 2509 additions and 140 deletions

59
src/lib/authStorage.ts Normal file
View File

@@ -0,0 +1,59 @@
/**
* Custom storage adapter for Supabase authentication that handles iframe localStorage restrictions.
* Falls back to sessionStorage or in-memory storage if localStorage is blocked.
*/
class AuthStorage {
private storage: Storage | null = null;
private memoryStorage: Map<string, string> = new Map();
private storageType: 'localStorage' | 'sessionStorage' | 'memory' = 'memory';
constructor() {
// Try localStorage first
try {
localStorage.setItem('__supabase_test__', 'test');
localStorage.removeItem('__supabase_test__');
this.storage = localStorage;
this.storageType = 'localStorage';
console.log('[AuthStorage] Using localStorage ✓');
} catch {
// Try sessionStorage as fallback
try {
sessionStorage.setItem('__supabase_test__', 'test');
sessionStorage.removeItem('__supabase_test__');
this.storage = sessionStorage;
this.storageType = 'sessionStorage';
console.warn('[AuthStorage] localStorage blocked, using sessionStorage ⚠️');
} catch {
// Use in-memory storage as last resort
this.storageType = 'memory';
console.error('[AuthStorage] Both localStorage and sessionStorage blocked, using in-memory storage ⛔');
console.error('[AuthStorage] Sessions will NOT persist across page reloads!');
}
}
}
getItem(key: string): string | null {
if (this.storage) {
return this.storage.getItem(key);
}
return this.memoryStorage.get(key) || null;
}
setItem(key: string, value: string): void {
if (this.storage) {
this.storage.setItem(key, value);
} else {
this.memoryStorage.set(key, value);
}
}
removeItem(key: string): void {
if (this.storage) {
this.storage.removeItem(key);
} else {
this.memoryStorage.delete(key);
}
}
}
export const authStorage = new AuthStorage();

View File

@@ -98,7 +98,7 @@ export const rideValidationSchema = z.object({
export const companyValidationSchema = z.object({
name: z.string().trim().min(1, 'Company name is required').max(200, 'Name must be less than 200 characters'),
slug: z.string().trim().min(1, 'Slug is required').regex(/^[a-z0-9-]+$/, 'Slug must contain only lowercase letters, numbers, and hyphens'),
company_type: z.enum(['manufacturer', 'designer', 'operator', 'property_owner']).optional(),
company_type: z.enum(['manufacturer', 'designer', 'operator', 'property_owner']),
description: z.string().max(2000, 'Description must be less than 2000 characters').optional(),
person_type: z.enum(['company', 'individual', 'firm', 'organization']),
founded_year: z.number().min(1800, 'Founded year must be after 1800').max(currentYear, `Founded year cannot be in the future`).optional(),