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/forgot.tsx

49 lines1,607 bytesCodeBlame
1import { Form, Link } from "react-router";
2
3import type { Route } from "./+types/forgot";
4import { page } from "../lib/meta";
5import { AuthCard } from "../components/auth-card";
6import { Button, Field, Input } from "../components/ui";
7import { identity } from "../lib/services.server";
8import { assertSameOrigin } from "../lib/session.server";
9
10export function meta(args: Route.MetaArgs) {
11 return page(args, { title: "Reset your password · g1t" });
12}
13
14export async function action({ request }: Route.ActionArgs) {
15 assertSameOrigin(request);
16 const form = await request.formData();
17 await identity.requestPasswordReset(String(form.get("email") ?? ""));
18 return { sent: true };
19}
20
21export default function Forgot({ actionData }: Route.ComponentProps) {
22 return (
23 <AuthCard
24 title="Forgot your password?"
25 subtitle="We will email you a link"
26 footer={
27 <Link to="/login" className="text-fg underline underline-offset-4">
28 Back to sign in
29 </Link>
30 }
31 >
32 {actionData?.sent ? (
33 <p className="rounded-lg border border-line bg-surface p-4 text-sm leading-6">
34 If that address has an account, a reset link is on its way. It works
35 for one hour.
36 </p>
37 ) : (
38 <Form method="post" className="space-y-4">
39 <Field label="Email">
40 <Input name="email" type="email" autoComplete="email" required autoFocus />
41 </Field>
42 <div className="pt-2 *:w-full">
43 <Button type="submit">Send reset link</Button>
44 </div>
45 </Form>
46 )}
47 </AuthCard>
48 );
49}