From c2b45166b8543fee285c5ec1ad2f47f395afdaa3 Mon Sep 17 00:00:00 2001 From: sirpiglr <49359077-sirpiglr@users.noreply.replit.com> Date: Sat, 6 Dec 2025 03:30:01 +0000 Subject: [PATCH] Update authentication flow and remove unused verification components Refactors authentication context and login page, removing manual verification UI and ensuring proper profile creation via auth state changes. Updates Supabase auth linking and unlinking types. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: ec4482a8-b3eb-4d1e-8edb-34a8f6b04f0b Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/fhRML7y Replit-Helium-Checkpoint-Created: true --- .replit | 4 ++ client/contexts/AuthContext.tsx | 15 ++++--- client/pages/Login.tsx | 74 ++++++--------------------------- 3 files changed, 24 insertions(+), 69 deletions(-) diff --git a/.replit b/.replit index 76d2fa09..9f5f7a49 100644 --- a/.replit +++ b/.replit @@ -60,6 +60,10 @@ externalPort = 3000 localPort = 40437 externalPort = 3001 +[[ports]] +localPort = 40897 +externalPort = 3002 + [deployment] deploymentTarget = "autoscale" run = ["node", "dist/server/production.mjs"] diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index 502178c9..685f3b12 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -533,8 +533,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ // ignore } - // Return user data for caller to use (e.g., Login.tsx) - return { user: data?.user ?? null }; + // Navigation is handled by AuthContext's useEffect watching user state } catch (error: any) { console.error("SignIn error details:", error); @@ -662,7 +661,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ } } - return { emailSent, verificationUrl } as const; + // Navigation is handled by AuthContext's useEffect watching user state } catch (error: any) { aethexToast.error({ title: "Sign up failed", @@ -786,7 +785,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ console.log("[Discord Link] Redirecting to Discord OAuth..."); - const u = new URL("/api/discord/oauth/start", apiBase); + const u = new URL("/api/discord/oauth/start", API_BASE); u.searchParams.set( "state", encodeURIComponent( @@ -812,10 +811,10 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ // For other providers (GitHub, Google), use Supabase's built-in linking try { - const { data, error } = (await supabase.auth.linkIdentity({ + const { data, error } = await (supabase.auth.linkIdentity as any)({ provider, redirectTo: `${window.location.origin}/dashboard?tab=connections`, - })) as any; + }); if (error) throw error; const linkUrl = data?.url; if (linkUrl) { @@ -875,10 +874,10 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ return; } try { - const { error } = (await supabase.auth.unlinkIdentity({ + const { error } = await (supabase.auth.unlinkIdentity as any)({ identity_id: identity.identity_id, provider, - })) as any; + }); if (error) throw error; await refreshAuthState(); aethexToast.success({ diff --git a/client/pages/Login.tsx b/client/pages/Login.tsx index 81a0f749..df73395c 100644 --- a/client/pages/Login.tsx +++ b/client/pages/Login.tsx @@ -63,9 +63,6 @@ export default function Login() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [fullName, setFullName] = useState(""); - const [manualVerificationLink, setManualVerificationLink] = useState< - string | null - >(null); const [showReset, setShowReset] = useState(false); const [resetEmail, setResetEmail] = useState(""); const [errorFromUrl, setErrorFromUrl] = useState(null); @@ -169,33 +166,19 @@ export default function Login() { try { if (isSignUp) { - const result = await signUp(email, password, { - data: { - full_name: fullName, - }, + await signUp(email, password, { + full_name: fullName, + }); + toastInfo({ + title: "Account created", + description: "Redirecting to onboarding...", }); - if (result?.user) { - toastInfo({ - title: "Account created", - description: - result?.identities?.length === 0 - ? "Please verify your email to log in" - : "Redirecting to onboarding...", - }); - await aethexUserService.ensureUserProfile(result.user); - navigate("/onboarding", { replace: true }); - } } else { - // Sign in with email/password - const result = await signIn(email, password); - if (result?.user) { - // Don't navigate immediately - let Auth context update and the useEffect below handle redirect - // This ensures profile data is fetched and profileComplete is properly calculated - toastInfo({ - title: "Signing you in", - description: "Redirecting...", - }); - } + await signIn(email, password); + toastInfo({ + title: "Signing you in", + description: "Redirecting...", + }); } } catch (error: any) { console.error("Auth error:", error); @@ -211,7 +194,7 @@ export default function Login() { } }; - const handleSocialLogin = async (provider: string) => { + const handleSocialLogin = async (provider: "github" | "google" | "discord") => { try { await signInWithOAuth(provider); } catch (error) { @@ -289,9 +272,8 @@ export default function Login() { return ( <>
@@ -354,36 +336,6 @@ export default function Login() { {errorFromUrl} ) : null} - {manualVerificationLink ? ( - - - Manual verification required - -

- We couldn't send the verification email automatically. - Use the link below to confirm your account: -

-

- {manualVerificationLink} -

- -
-
- ) : null} {/* Social Login Buttons */}