import { useState } from 'react'; import { supabase } from '../supabaseClient'; import { Mail, Lock, ShieldCheck, ArrowRight } from 'lucide-react'; export default function Auth() { const [isSignUp, setIsSignUp] = useState(false); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [message, setMessage] = useState<{ type: 'error' | 'success'; text: string } | null>(null); const handleAuth = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setMessage(null); try { if (isSignUp) { const { error } = await supabase.auth.signUp({ email, password, }); if (error) throw error; setMessage({ type: 'success', text: 'Registration successful! Check your email for validation link.' }); } else { const { error } = await supabase.auth.signInWithPassword({ email, password, }); if (error) throw error; } } catch (err: any) { setMessage({ type: 'error', text: err.message || 'An error occurred during authentication' }); } finally { setLoading(false); } }; const handleGoogleSignIn = async () => { try { setLoading(true); const redirectUrl = window.location.origin.endsWith('/') ? window.location.origin : `${window.location.origin}/`; alert('Sending redirect URL: ' + redirectUrl); const { error } = await supabase.auth.signInWithOAuth({ provider: 'google', options: { redirectTo: redirectUrl } }); if (error) throw error; } catch (err: any) { setMessage({ type: 'error', text: err.message || 'Google OAuth failed to initialize' }); setLoading(false); } }; const handleSandboxEntrance = () => { localStorage.setItem('algospaced_sandbox_mode', 'true'); window.location.reload(); }; return (
Google Sign-In is restricted inside Hugging Face's iframe wrapper due to browser security.
OPEN FULLSCREEN / MOBILE SITESpaced Repetition for DSA