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"; |
| Initial g1t: services, event bus, intents and attempts | 2 | |
| 3 | import type { Route } from "./+types/login"; | |
| Social cards for every page: og.g1t.sh | 4 | import { page } from "../lib/meta"; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 5 | import { useInviteOnly } from "../lib/registration"; |
| API and MCP server, Rust identity service, registration, site redesign | 6 | import { AuthCard } from "../components/auth-card"; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 7 | import { ContinueWithGithub, GithubMark, OrDivider } from "../components/github"; |
| Merge membership: owners, org roles, GitHub's repo roles, privileges, 2FA | 8 | import { PENDING_COOKIE, TWO_FACTOR_COOKIE, TWO_FACTOR_SECONDS, cookie, readCookie } from "../lib/github"; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 9 | import { githubSignIn, githubSignInEnabled } from "../lib/github.server"; |
| Merge branch 'worktree-agent-a985c01f43538af01' | 10 | import { ErrorText, Field, Input, SubmitButton } from "../components/ui"; |
| API and MCP server, Rust identity service, registration, site redesign | 11 | import { identity } from "../lib/services.server"; |
| Initial g1t: services, event bus, intents and attempts | 12 | import { |
| 13 | assertSameOrigin, | |
| 14 | getViewer, | |
| API and MCP server, Rust identity service, registration, site redesign | 15 | nextPath, |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 16 | clientOf, |
| Initial g1t: services, event bus, intents and attempts | 17 | startSession, |
| 18 | } from "../lib/session.server"; | |
| 19 | ||
| Social cards for every page: og.g1t.sh | 20 | export function meta(args: Route.MetaArgs) { |
| 21 | return page(args, { title: "Sign in · g1t" }); | |
| Initial g1t: services, event bus, intents and attempts | 22 | } |
| 23 | ||
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 24 | export async function loader({ request, context }: Route.LoaderArgs) { |
| Initial g1t: services, event bus, intents and attempts | 25 | if (getViewer(context)) throw redirect(nextPath(request)); |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 26 | // A GitHub sign-in whose email belongs to an account: signing in to it |
| 27 | // links GitHub, and nothing is linked before then. | |
| 28 | const pending = readCookie(request.headers.get("cookie"), PENDING_COOKIE); | |
| 29 | const held = pending ? await githubSignIn.pending(pending).catch(() => null) : null; | |
| 30 | return { | |
| 31 | next: nextPath(request), | |
| 32 | github: await githubSignInEnabled(), | |
| 33 | linking: held?.ok ? held.value.login : null, | |
| 34 | }; | |
| Initial g1t: services, event bus, intents and attempts | 35 | } |
| 36 | ||
| 37 | export async function action({ request }: Route.ActionArgs) { | |
| 38 | assertSameOrigin(request); | |
| 39 | const form = await request.formData(); | |
| API and MCP server, Rust identity service, registration, site redesign | 40 | const result = await identity.signIn( |
| 41 | String(form.get("username") ?? "").trim(), | |
| 42 | String(form.get("password") ?? ""), | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 43 | clientOf(request), |
| API and MCP server, Rust identity service, registration, site redesign | 44 | ); |
| Initial g1t: services, event bus, intents and attempts | 45 | if (!result.ok) return { error: result.error.message }; |
| Merge membership: owners, org roles, GitHub's repo roles, privileges, 2FA | 46 | // Two-factor authentication on: no session yet, a code first. |
| 47 | if (result.value.twoFactorChallenge) { | |
| 48 | const next = nextPath(request); | |
| 49 | throw redirect(`/login/two-factor${next === "/" ? "" : `?next=${encodeURIComponent(next)}`}`, { | |
| 50 | headers: { "set-cookie": cookie(TWO_FACTOR_COOKIE, result.value.twoFactorChallenge, TWO_FACTOR_SECONDS) }, | |
| 51 | }); | |
| 52 | } | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 53 | const headers = new Headers({ "set-cookie": startSession(result.value.sessionToken) }); |
| 54 | const pending = readCookie(request.headers.get("cookie"), PENDING_COOKIE); | |
| 55 | if (pending) { | |
| 56 | await githubSignIn.claim(pending, result.value.user).catch(() => null); | |
| 57 | headers.append("set-cookie", cookie(PENDING_COOKIE, "", 0)); | |
| 58 | } | |
| 59 | throw redirect(nextPath(request), { headers }); | |
| Initial g1t: services, event bus, intents and attempts | 60 | } |
| 61 | ||
| Device sign-in replaces registering and minting tokens over the API | 62 | export default function Login({ loaderData, actionData }: Route.ComponentProps) { |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 63 | const inviteOnly = useInviteOnly(); |
| Device sign-in replaces registering and minting tokens over the API | 64 | const registerUrl = |
| 65 | loaderData.next === "/" | |
| 66 | ? "/register" | |
| 67 | : `/register?next=${encodeURIComponent(loaderData.next)}`; | |
| Initial g1t: services, event bus, intents and attempts | 68 | return ( |
| API and MCP server, Rust identity service, registration, site redesign | 69 | <AuthCard |
| 70 | title="Welcome back" | |
| 71 | subtitle="Sign in to g1t" | |
| 72 | footer={ | |
| 73 | <> | |
| 74 | New to g1t?{" "} | |
| Device sign-in replaces registering and minting tokens over the API | 75 | <Link to={registerUrl} className="text-fg underline underline-offset-4"> |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 76 | {inviteOnly ? "Request access or use an invite" : "Create an account"} |
| API and MCP server, Rust identity service, registration, site redesign | 77 | </Link> |
| 78 | </> | |
| 79 | } | |
| 80 | > | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 81 | {loaderData.linking ? ( |
| 82 | <p className="mb-6 flex items-start gap-2 rounded-md border border-accent/40 bg-surface p-3 text-sm" role="status"> | |
| 83 | <GithubMark className="mt-0.5 size-4 shrink-0" /> | |
| 84 | <span> | |
| 85 | An account with this email exists. Sign in to link GitHub ( | |
| 86 | <span className="font-mono">@{loaderData.linking}</span>) to it. | |
| 87 | </span> | |
| 88 | </p> | |
| 89 | ) : ( | |
| 90 | loaderData.github && ( | |
| 91 | <> | |
| 92 | <ContinueWithGithub href={loaderData.next === "/" ? "/auth/github" : `/auth/github?next=${encodeURIComponent(loaderData.next)}`} /> | |
| 93 | <OrDivider /> | |
| 94 | </> | |
| 95 | ) | |
| 96 | )} | |
| API and MCP server, Rust identity service, registration, site redesign | 97 | <Form method="post" className="space-y-4"> |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 98 | <Field label="Username or email"> |
| Initial g1t: services, event bus, intents and attempts | 99 | <Input name="username" autoComplete="username" required autoFocus /> |
| 100 | </Field> | |
| 101 | <Field label="Password"> | |
| 102 | <Input | |
| 103 | name="password" | |
| 104 | type="password" | |
| 105 | autoComplete="current-password" | |
| 106 | required | |
| 107 | /> | |
| 108 | </Field> | |
| 109 | <ErrorText>{actionData?.error}</ErrorText> | |
| 110 | <div className="pt-2 *:w-full"> | |
| Merge branch 'worktree-agent-a985c01f43538af01' | 111 | <SubmitButton pending="Signing in…">Sign in</SubmitButton> |
| Initial g1t: services, event bus, intents and attempts | 112 | </div> |
| Email verification, password reset, and Git for AI scale positioning | 113 | <p className="text-center text-sm"> |
| 114 | <Link to="/forgot" className="text-muted hover:text-fg"> | |
| 115 | Forgot your password? | |
| 116 | </Link> | |
| 117 | </p> | |
| Initial g1t: services, event bus, intents and attempts | 118 | </Form> |
| API and MCP server, Rust identity service, registration, site redesign | 119 | </AuthCard> |
| Initial g1t: services, event bus, intents and attempts | 120 | ); |
| 121 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.