g1t/apps/web/app/routes/login.tsx

74 lines2,153 bytesCodeBlame

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 redesign1import { Form, Link, redirect } from "react-router";
Initial g1t: services, event bus, intents and attempts2
3import type { Route } from "./+types/login";
API and MCP server, Rust identity service, registration, site redesign4import { AuthCard } from "../components/auth-card";
Initial g1t: services, event bus, intents and attempts5import { Button, ErrorText, Field, Input } from "../components/ui";
API and MCP server, Rust identity service, registration, site redesign6import { identity } from "../lib/services.server";
Initial g1t: services, event bus, intents and attempts7import {
8 assertSameOrigin,
9 getViewer,
API and MCP server, Rust identity service, registration, site redesign10 nextPath,
Initial g1t: services, event bus, intents and attempts11 startSession,
12} from "../lib/session.server";
13
14export function meta({}: Route.MetaArgs) {
15 return [{ title: "Sign in · g1t" }];
16}
17
18export function loader({ request, context }: Route.LoaderArgs) {
19 if (getViewer(context)) throw redirect(nextPath(request));
20 return null;
21}
22
23export async function action({ request }: Route.ActionArgs) {
24 assertSameOrigin(request);
25 const form = await request.formData();
API and MCP server, Rust identity service, registration, site redesign26 const result = await identity.signIn(
27 String(form.get("username") ?? "").trim(),
28 String(form.get("password") ?? ""),
29 );
Initial g1t: services, event bus, intents and attempts30 if (!result.ok) return { error: result.error.message };
31 throw redirect(nextPath(request), {
32 headers: { "set-cookie": startSession(result.value.sessionToken) },
33 });
34}
35
36export default function Login({ actionData }: Route.ComponentProps) {
37 return (
API and MCP server, Rust identity service, registration, site redesign38 <AuthCard
39 title="Welcome back"
40 subtitle="Sign in to g1t"
41 footer={
42 <>
43 New to g1t?{" "}
44 <Link to="/register" className="text-fg underline underline-offset-4">
45 Create an account
46 </Link>
47 </>
48 }
49 >
50 <Form method="post" className="space-y-4">
Initial g1t: services, event bus, intents and attempts51 <Field label="Username">
52 <Input name="username" autoComplete="username" required autoFocus />
53 </Field>
54 <Field label="Password">
55 <Input
56 name="password"
57 type="password"
58 autoComplete="current-password"
59 required
60 />
61 </Field>
62 <ErrorText>{actionData?.error}</ErrorText>
63 <div className="pt-2 *:w-full">
64 <Button type="submit">Sign in</Button>
65 </div>
Email verification, password reset, and Git for AI scale positioning66 <p className="text-center text-sm">
67 <Link to="/forgot" className="text-muted hover:text-fg">
68 Forgot your password?
69 </Link>
70 </p>
Initial g1t: services, event bus, intents and attempts71 </Form>
API and MCP server, Rust identity service, registration, site redesign72 </AuthCard>
Initial g1t: services, event bus, intents and attempts73 );
74}