diff --git a/src/pages/Auth.tsx b/src/pages/Auth.tsx index 16457f65..ad0375b6 100644 --- a/src/pages/Auth.tsx +++ b/src/pages/Auth.tsx @@ -11,11 +11,12 @@ import { Separator } from '@/components/ui/separator'; import { Zap, Mail, Lock, User, AlertCircle, Eye, EyeOff } from 'lucide-react'; import { supabase } from '@/integrations/supabase/client'; import { useToast } from '@/hooks/use-toast'; - export default function Auth() { const [searchParams] = useSearchParams(); const navigate = useNavigate(); - const { toast } = useToast(); + const { + toast + } = useToast(); const [loading, setLoading] = useState(false); const [showPassword, setShowPassword] = useState(false); const [formData, setFormData] = useState({ @@ -25,72 +26,67 @@ export default function Auth() { username: '', displayName: '' }); - const defaultTab = searchParams.get('tab') || 'signin'; - const handleInputChange = (e: React.ChangeEvent) => { setFormData(prev => ({ ...prev, [e.target.name]: e.target.value })); }; - const handleSignIn = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); - try { - const { data, error } = await supabase.auth.signInWithPassword({ + const { + data, + error + } = await supabase.auth.signInWithPassword({ email: formData.email, - password: formData.password, + password: formData.password }); - if (error) throw error; - toast({ title: "Welcome back!", - description: "You've been signed in successfully.", + description: "You've been signed in successfully." }); - const redirectTo = searchParams.get('redirect') || '/'; navigate(redirectTo); } catch (error: any) { toast({ variant: "destructive", title: "Sign in failed", - description: error.message, + description: error.message }); } finally { setLoading(false); } }; - const handleSignUp = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); - if (formData.password !== formData.confirmPassword) { toast({ variant: "destructive", title: "Passwords don't match", - description: "Please make sure your passwords match.", + description: "Please make sure your passwords match." }); setLoading(false); return; } - if (formData.password.length < 6) { toast({ variant: "destructive", title: "Password too short", - description: "Password must be at least 6 characters long.", + description: "Password must be at least 6 characters long." }); setLoading(false); return; } - try { - const { data, error } = await supabase.auth.signUp({ + const { + data, + error + } = await supabase.auth.signUp({ email: formData.email, password: formData.password, options: { @@ -100,57 +96,49 @@ export default function Auth() { } } }); - if (error) throw error; - toast({ title: "Welcome to ThrillWiki!", - description: "Please check your email to verify your account.", + description: "Please check your email to verify your account." }); - navigate('/'); } catch (error: any) { toast({ variant: "destructive", title: "Sign up failed", - description: error.message, + description: error.message }); } finally { setLoading(false); } }; - const handleSocialSignIn = async (provider: 'google' | 'discord') => { try { - const { error } = await supabase.auth.signInWithOAuth({ + const { + error + } = await supabase.auth.signInWithOAuth({ provider, options: { redirectTo: `${window.location.origin}/auth/callback` } }); - if (error) throw error; } catch (error: any) { toast({ variant: "destructive", title: "Social sign in failed", - description: error.message, + description: error.message }); } }; - - return ( -
+ return
-
- -
-
+

ThrillWiki

@@ -180,16 +168,7 @@ export default function Auth() {
- +
@@ -197,23 +176,8 @@ export default function Auth() {
- -
@@ -237,26 +201,18 @@ export default function Auth() {
- - @@ -279,26 +235,12 @@ export default function Auth() {
- +
- +
@@ -306,16 +248,7 @@ export default function Auth() {
- +
@@ -323,23 +256,8 @@ export default function Auth() {
- -
@@ -349,16 +267,7 @@ export default function Auth() {
- +
@@ -377,26 +286,18 @@ export default function Auth() {
- - @@ -415,6 +316,5 @@ export default function Auth() {
- - ); + ; } \ No newline at end of file