diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-20 18:10:47 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-20 18:10:47 +1100 |
commit | 084dc0be08555891cad4c2bb984822a62ec5ec9f (patch) | |
tree | ed2ca0fafefa2224ae32761f955f63935422a97d /src/api/util/utility/captcha.ts | |
parent | fix: route file regex (#956) (diff) | |
download | server-084dc0be08555891cad4c2bb984822a62ec5ec9f.tar.xz |
Add ESLint (#941)
* Add eslint, switch to lint-staged for precommit * Fix all ESLint errors * Update GH workflow to check prettier and eslint
Diffstat (limited to 'src/api/util/utility/captcha.ts')
-rw-r--r-- | src/api/util/utility/captcha.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/api/util/utility/captcha.ts b/src/api/util/utility/captcha.ts index 2d31f891..bd05582f 100644 --- a/src/api/util/utility/captcha.ts +++ b/src/api/util/utility/captcha.ts @@ -47,7 +47,10 @@ export async function verifyCaptcha(response: string, ip?: string) { const { security } = Config.get(); const { service, secret, sitekey } = security.captcha; - if (!service) throw new Error("Cannot verify captcha without service"); + if (!service || !secret || !sitekey) + throw new Error( + "CAPTCHA is not configured correctly. https://docs.fosscord.com/setup/server/security/captcha/", + ); const res = await fetch(verifyEndpoints[service], { method: "POST", @@ -56,9 +59,9 @@ export async function verifyCaptcha(response: string, ip?: string) { }, body: `response=${encodeURIComponent(response)}` + - `&secret=${encodeURIComponent(secret!)}` + - `&sitekey=${encodeURIComponent(sitekey!)}` + - (ip ? `&remoteip=${encodeURIComponent(ip!)}` : ""), + `&secret=${encodeURIComponent(secret)}` + + `&sitekey=${encodeURIComponent(sitekey)}` + + (ip ? `&remoteip=${encodeURIComponent(ip)}` : ""), }); return (await res.json()) as hcaptchaResponse | recaptchaResponse; |