From 32a255d247a412143beec350bd9559b635aedcef Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 28 Sep 2025 14:55:58 +0000 Subject: [PATCH] Add Magic Link sign-in --- src/pages/Auth.tsx | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) 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 +
++ Skip the password - just enter your email above +
+