Skip to content

Commit 5414e70

Browse files
committed
check score
1 parent d56fbdc commit 5414e70

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/routes/-components/newsletter.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ export const subscribeFn = createServerFn()
2323
body: `secret=${env.RECAPTCHA_SECRET_KEY}&response=${data.recaptchaToken}`,
2424
}
2525
);
26-
const json = (await response.json()) as { success: boolean };
26+
const json = (await response.json()) as {
27+
success: boolean;
28+
score: number;
29+
};
30+
2731
if (!json.success) {
2832
throw new Error("invalid recaptcha token");
2933
}
3034

35+
if (json.score < 0.5) {
36+
throw new Error("recaptcha score too low");
37+
}
38+
3139
const params = new URLSearchParams();
3240
params.append("email", data.email);
3341
await fetch(env.MAILING_LIST_ENDPOINT, {

0 commit comments

Comments
 (0)