diff --git a/src/pages/Auth.tsx b/src/pages/Auth.tsx index ad0375b6..3d9f1a69 100644 --- a/src/pages/Auth.tsx +++ b/src/pages/Auth.tsx @@ -18,6 +18,7 @@ export default function Auth() { toast } = useToast(); const [loading, setLoading] = useState(false); + const [magicLinkLoading, setMagicLinkLoading] = useState(false); const [showPassword, setShowPassword] = useState(false); const [formData, setFormData] = useState({ email: '', @@ -112,6 +113,44 @@ export default function Auth() { setLoading(false); } }; + + const handleMagicLinkSignIn = async (email: string) => { + if (!email) { + toast({ + variant: "destructive", + title: "Email required", + description: "Please enter your email address to receive a magic link." + }); + return; + } + + setMagicLinkLoading(true); + + try { + const { error } = await supabase.auth.signInWithOtp({ + email, + options: { + emailRedirectTo: `${window.location.origin}/` + } + }); + + if (error) throw error; + + toast({ + title: "Magic link sent!", + description: "Check your email for a sign-in link." + }); + } catch (error: any) { + toast({ + variant: "destructive", + title: "Failed to send magic link", + description: error.message + }); + } finally { + setMagicLinkLoading(false); + } + }; + const handleSocialSignIn = async (provider: 'google' | 'discord') => { try { const { @@ -188,6 +227,21 @@ export default function Auth() { +
+ +

+ Enter your email above and click to receive a sign-in link +

+
+
@@ -276,6 +330,21 @@ export default function Auth() { +
+ +

+ Skip the password - just enter your email above +

+
+