MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / LoginPage

Function LoginPage

apps/host-selfhost/web/login.tsx:19–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17// redeeming an invite — either the full /join/<code> link, or by entering the
18// code here ("Have an invite code?"), which forwards to the same join page.
19export const LoginPage = () => {
20 // Where to go after sign-in. The gate renders this page IN PLACE of the
21 // requested route without navigating, so the live location is what carries a
22 // deep link (`/connect/linear`) across sign-in — see `postLoginTarget`.
23 const postLogin = postLoginTarget(window.location);
24 const [mode, setMode] = useState<"signin" | "code">("signin");
25 const [email, setEmail] = useState("");
26 const [password, setPassword] = useState("");
27 const [code, setCode] = useState("");
28 const [error, setError] = useState<string | null>(null);
29 const [busy, setBusy] = useState(false);
30
31 const signIn = async (event: FormEvent) => {
32 event.preventDefault();
33 setBusy(true);
34 setError(null);
35 const result = await authClient.signIn.email({ email, password });
36 if (result.error) {
37 setBusy(false);
38 setError(result.error.message ?? "Sign in failed");
39 return;
40 }
41 window.location.href = postLogin;
42 };
43
44 const redeem = (event: FormEvent) => {
45 event.preventDefault();
46 const trimmed = code.trim();
47 if (!trimmed) return;
48 // Forward to the join page, which collects name/email/password and redeems.
49 window.location.href = `/join/${encodeURIComponent(trimmed)}`;
50 };
51
52 return (
53 <AuthLayout>
54 <div className="w-full max-w-sm space-y-4 rounded-xl border border-border bg-card p-6 shadow-sm">
55 <div className="space-y-1">
56 <h1 className="text-xl font-semibold tracking-tight text-foreground">
57 {mode === "signin" ? "Sign in" : "Join this instance"}
58 </h1>
59 <p className="text-sm text-muted-foreground">
60 {mode === "signin"
61 ? "Welcome back. Use your instance account."
62 : "Enter the invite code you were given."}
63 </p>
64 </div>
65
66 {mode === "signin" ? (
67 <form onSubmit={signIn} className="space-y-4">
68 <div className="space-y-1.5">
69 <Label htmlFor="email">Email</Label>
70 <Input
71 id="email"
72 type="email"
73 placeholder="you@example.com"
74 value={email}
75 onChange={(e) => setEmail((e.target as HTMLInputElement).value)}
76 autoComplete="email"

Callers

nothing calls this directly

Calls 2

postLoginTargetFunction · 0.90
setPasswordFunction · 0.85

Tested by

no test coverage detected