Skip to content

Commit aa4f0a4

Browse files
committed
returning false if response was not ok
1 parent 1ca0fd1 commit aa4f0a4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

backend/src/utils/captcha.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export async function verify(captcha: string): Promise<boolean> {
1919
body: `secret=${process.env.RECAPTCHA_SECRET}&response=${captcha}`,
2020
}
2121
);
22-
const captchaData = (await response.json()) as CaptchaData;
23-
return captchaData.success;
22+
23+
if (!response.ok) {
24+
return false;
25+
} else {
26+
const captchaData = (await response.json()) as CaptchaData;
27+
return captchaData.success;
28+
}
2429
}

0 commit comments

Comments
 (0)