g1t/apps/web/app/routes/register.tsx
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| API and MCP server, Rust identity service, registration, site redesign | 1 | import { Form, Link, redirect } from "react-router"; |
| 2 | ||
| 3 | import type { Route } from "./+types/register"; | |
| Social cards for every page: og.g1t.sh | 4 | import { page } from "../lib/meta"; |
| API and MCP server, Rust identity service, registration, site redesign | 5 | import { AuthCard } from "../components/auth-card"; |
| 6 | import { Button, ErrorText, Field, Input } from "../components/ui"; | |
| 7 | import { identity } from "../lib/services.server"; | |
| 8 | import { | |
| 9 | assertSameOrigin, | |
| 10 | getViewer, | |
| Device sign-in replaces registering and minting tokens over the API | 11 | nextPath, |
| API and MCP server, Rust identity service, registration, site redesign | 12 | startSession, |
| 13 | } from "../lib/session.server"; | |
| 14 | ||
| Social cards for every page: og.g1t.sh | 15 | export function meta(args: Route.MetaArgs) { |
| 16 | return page(args, { title: "Create an account · g1t" }); | |
| API and MCP server, Rust identity service, registration, site redesign | 17 | } |
| 18 | ||
| Device sign-in replaces registering and minting tokens over the API | 19 | export function loader({ request, context }: Route.LoaderArgs) { |
| 20 | if (getViewer(context)) throw redirect(nextPath(request)); | |
| API and MCP server, Rust identity service, registration, site redesign | 21 | return null; |
| 22 | } | |
| 23 | ||
| 24 | export async function action({ request }: Route.ActionArgs) { | |
| 25 | assertSameOrigin(request); | |
| 26 | const form = await request.formData(); | |
| 27 | const result = await identity.register( | |
| 28 | String(form.get("username") ?? ""), | |
| 29 | String(form.get("email") ?? ""), | |
| 30 | String(form.get("password") ?? ""), | |
| 31 | ); | |
| 32 | if (!result.ok) return { error: result.error.message }; | |
| Device sign-in replaces registering and minting tokens over the API | 33 | throw redirect(nextPath(request), { |
| API and MCP server, Rust identity service, registration, site redesign | 34 | headers: { "set-cookie": startSession(result.value.sessionToken) }, |
| 35 | }); | |
| 36 | } | |
| 37 | ||
| 38 | export default function Register({ actionData }: Route.ComponentProps) { | |
| 39 | return ( | |
| 40 | <AuthCard | |
| 41 | title="Create your account" | |
| Email verification, password reset, and Git for AI scale positioning | 42 | subtitle="Git for AI scale" |
| API and MCP server, Rust identity service, registration, site redesign | 43 | footer={ |
| 44 | <> | |
| 45 | Already have an account?{" "} | |
| 46 | <Link to="/login" className="text-fg underline underline-offset-4"> | |
| 47 | Sign in | |
| 48 | </Link> | |
| 49 | </> | |
| 50 | } | |
| 51 | > | |
| 52 | <Form method="post" className="space-y-4"> | |
| 53 | <Field | |
| 54 | label="Username" | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 55 | hint="Lowercase letters, digits and hyphens. It is how you sign in and how others see you." |
| API and MCP server, Rust identity service, registration, site redesign | 56 | > |
| 57 | <Input | |
| 58 | name="username" | |
| 59 | autoComplete="username" | |
| 60 | required | |
| 61 | autoFocus | |
| 62 | maxLength={39} | |
| 63 | pattern="[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9]))*" | |
| 64 | /> | |
| 65 | </Field> | |
| 66 | <Field label="Email"> | |
| 67 | <Input name="email" type="email" autoComplete="email" required /> | |
| 68 | </Field> | |
| 69 | <Field label="Password" hint="At least 10 characters."> | |
| 70 | <Input | |
| 71 | name="password" | |
| 72 | type="password" | |
| 73 | autoComplete="new-password" | |
| 74 | required | |
| 75 | minLength={10} | |
| 76 | /> | |
| 77 | </Field> | |
| 78 | <ErrorText>{actionData?.error}</ErrorText> | |
| 79 | <div className="pt-2 *:w-full"> | |
| 80 | <Button type="submit">Create account</Button> | |
| 81 | </div> | |
| 82 | </Form> | |
| 83 | </AuthCard> | |
| 84 | ); | |
| 85 | } |