LW

Welcome to LightWeight

Your AI-powered diet tracking companion

Secure authentication powered by Supabase

© 2024 LightWeight. All rights reserved.

nction handleBiometricSignIn() { if (isLoading) return; if (!biometricService.isBiometricEnabled()) { showMessage('Biometric authentication is not enabled', 'error'); return; } setLoading(true); try { const credentials = await biometricService.authenticateWithBiometric(); await handleSignIn(credentials.email, credentials.password); } catch (error) { console.error('Biometric sign in error:', error); if (error.name === 'NotAllowedError') { showMessage('Biometric authentication was cancelled', 'error'); } else if (error.message.includes('not enabled')) { showMessage('Biometric authentication is not enabled', 'error'); } else { showMessage('Biometric authentication failed. Please try signing in manually.', 'error'); } } finally { setLoading(false); } } // Check for existing session on load document.addEventListener('DOMContentLoaded', function() { const existingSession = localStorage.getItem('lw_session'); if (existingSession) { try { const session = JSON.parse(existingSession); const now = Date.now() / 1000; if (session.expires_at && session.expires_at > now) { showMessage('You are already signed in. Redirecting...', 'success'); setTimeout(() => { window.location.href = MAIN_APP_URL; }, 1500); return; } } catch (error) { console.error('Error checking existing session:', error); } // Clear expired session localStorage.removeItem('lw_session'); } });