From 465ff9a10ed35399824669ec4d14a069c775489c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= <35082514+alezmad@users.noreply.github.com> Date: Mon, 13 Apr 2026 09:06:42 +0100 Subject: [PATCH] fix(web): rewrite CLI auth login as standalone component Remove dependency on SocialProviders/RegisterForm which need React Query providers. Self-contained with authClient directly. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../app/[locale]/cli-auth/cli-auth-login.tsx | 145 ++++++++++++++---- 1 file changed, 116 insertions(+), 29 deletions(-) diff --git a/apps/web/src/app/[locale]/cli-auth/cli-auth-login.tsx b/apps/web/src/app/[locale]/cli-auth/cli-auth-login.tsx index 8445174..f285af8 100644 --- a/apps/web/src/app/[locale]/cli-auth/cli-auth-login.tsx +++ b/apps/web/src/app/[locale]/cli-auth/cli-auth-login.tsx @@ -1,11 +1,7 @@ "use client"; -import { SocialProvider } from "@turbostarter/auth"; - -import { authConfig } from "~/config/auth"; -import { SocialProviders } from "~/modules/auth/form/social-providers"; -import { RegisterForm } from "~/modules/auth/form/register-form"; -import { AuthDivider } from "~/modules/auth/layout/divider"; +import { useState } from "react"; +import { authClient } from "~/lib/auth/client"; interface Props { code: string; @@ -13,45 +9,136 @@ interface Props { export function CliAuthLogin({ code }: Props) { const redirectTo = `/cli-auth?code=${encodeURIComponent(code)}`; + const [loading, setLoading] = useState(null); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [name, setName] = useState(""); + const [mode, setMode] = useState<"login" | "register">("login"); + const [error, setError] = useState(""); + + const handleSocial = async (provider: "google" | "github") => { + setLoading(provider); + setError(""); + try { + await authClient.signIn.social({ + provider, + callbackURL: redirectTo, + }); + } catch (e) { + setError(e instanceof Error ? e.message : "Sign-in failed"); + setLoading(null); + } + }; + + const handleEmailSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setLoading("email"); + setError(""); + try { + if (mode === "register") { + await authClient.signUp.email({ + email, + password, + name: name || email.split("@")[0] || "User", + callbackURL: redirectTo, + }); + } else { + await authClient.signIn.email({ + email, + password, + callbackURL: redirectTo, + }); + } + window.location.href = redirectTo; + } catch (e) { + setError(e instanceof Error ? e.message : "Failed"); + setLoading(null); + } + }; + + const btnBase = "w-full flex items-center justify-center gap-3 rounded-lg px-4 py-3 text-[15px] font-medium transition-all"; + const btnOutline = `${btnBase} border border-[var(--cm-border,#333)] text-[var(--cm-fg,#fafafa)] hover:bg-[var(--cm-bg-elevated,#1a1a1a)]`; + const btnPrimary = `${btnBase} bg-[var(--cm-clay,#b07a56)] text-[var(--cm-fg,#fafafa)] hover:opacity-90`; + const inputBase = "w-full rounded-lg border border-[var(--cm-border,#333)] bg-[var(--cm-bg,#0a0a0a)] px-4 py-3 text-[15px] text-[var(--cm-fg,#fafafa)] placeholder:text-[var(--cm-fg-muted,#666)] focus:outline-none focus:ring-2 focus:ring-[var(--cm-clay,#b07a56)]/50 focus:border-[var(--cm-clay,#b07a56)]"; return ( -
+
{/* Header */}
-
- cm +
+ + + + + + +
-

+

Connect to claudemesh CLI

-

- Sign in or create an account to connect your terminal session. +

+ {mode === "login" ? "Sign in" : "Create an account"} to connect your terminal session.

- {/* Social providers */} - + {/* Social buttons */} +
+ + +
- + {/* Divider */} +
+
+ or +
+
- {/* Email + password form */} - + {/* Email form */} +
+ {mode === "register" && ( + setName(e.target.value)} className={inputBase} /> + )} + setEmail(e.target.value)} required className={inputBase} /> + setPassword(e.target.value)} required minLength={8} className={inputBase} /> - {/* Device code footer */} + {error &&

{error}

} + + +
+ + {/* Toggle mode */} +

+ {mode === "login" ? ( + <>Don't have an account?{" "} + ) : ( + <>Already have an account?{" "} + )} +

+ + {/* Device code */}
-
+
{code}
-

+

Confirm this code matches your terminal