Skip to content

Commit

Permalink
add honeypot to reset password
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-g committed Apr 3, 2024
1 parent b0554c7 commit be0e406
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/routes/_layout.reset-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { parse } from "@conform-to/zod"
import { useForm, conform } from "@conform-to/react"
import { z } from "zod"
import { mergeMeta } from "~/merge-meta"
import { HoneypotInputs } from "~/components/honeypot"
import { checkHoneypot } from "~/honeypot.server"

export const loader = async ({ request, params }: LoaderFunctionArgs) => {
const userId = await getUserId(request)
Expand All @@ -37,6 +39,7 @@ const schema = z

export const action = async ({ request }: ActionFunctionArgs) => {
const formData = await request.formData()
checkHoneypot(formData)
const submission = parse(formData, { schema })
if (!submission.value || submission.intent !== "submit") {
return json(submission, { status: 400 })
Expand Down Expand Up @@ -71,6 +74,7 @@ export default function ResetPasswordPage() {
<>
<h2>Reset password</h2>
<Form method="post" {...form.props}>
<HoneypotInputs />
<Stack gap={16}>
{resetToken && (
<>
Expand Down

0 comments on commit be0e406

Please sign in to comment.