flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

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

59 lines1,906 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.

Email verification, password reset, and Git for AI scale positioning1import { Form, Link, redirect } from "react-router";
2
3import type { Route } from "./+types/reset";
Social cards for every page: og.g1t.sh4import { page } from "../lib/meta";
Email verification, password reset, and Git for AI scale positioning5import { AuthCard } from "../components/auth-card";
6import { Button, ErrorText, Field, Input } from "../components/ui";
7import { identity } from "../lib/services.server";
8import { assertSameOrigin } from "../lib/session.server";
9
Social cards for every page: og.g1t.sh10export function meta(args: Route.MetaArgs) {
11 return page(args, { title: "Choose a new password · g1t" });
Email verification, password reset, and Git for AI scale positioning12}
13
14export function loader({ request }: Route.LoaderArgs) {
15 return { token: new URL(request.url).searchParams.get("token") ?? "" };
16}
17
18export async function action({ request }: Route.ActionArgs) {
19 assertSameOrigin(request);
20 const form = await request.formData();
21 const result = await identity.resetPassword(
22 String(form.get("token") ?? ""),
23 String(form.get("password") ?? ""),
24 );
25 if (!result.ok) return { error: result.error.message };
26 throw redirect("/login?reset=1");
27}
28
29export default function Reset({ loaderData, actionData }: Route.ComponentProps) {
30 return (
31 <AuthCard
32 title="Choose a new password"
33 subtitle="You will be signed out everywhere"
34 footer={
35 <Link to="/login" className="text-fg underline underline-offset-4">
36 Back to sign in
37 </Link>
38 }
39 >
40 <Form method="post" className="space-y-4">
41 <input type="hidden" name="token" value={loaderData.token} />
42 <Field label="New password" hint="At least 10 characters.">
43 <Input
44 name="password"
45 type="password"
46 autoComplete="new-password"
47 required
48 minLength={10}
49 autoFocus
50 />
51 </Field>
52 <ErrorText>{actionData?.error}</ErrorText>
53 <div className="pt-2 *:w-full">
54 <Button type="submit">Set password</Button>
55 </div>
56 </Form>
57 </AuthCard>
58 );
59}