diff --git a/middlewares/verifyCaptcha.ts b/middlewares/verifyCaptcha.ts index 138b207..e40261e 100644 --- a/middlewares/verifyCaptcha.ts +++ b/middlewares/verifyCaptcha.ts @@ -14,30 +14,24 @@ export class VerifyCaptcha { } async verifyV2Token(v2Token: string): Promise { + console.log("Recaptcha V2 Token:", v2Token) if(v2Token) { - const URL = "https://www.google.com/recaptcha/api/siteverify" + const URL = `https://www.google.com/recaptcha/api/siteverify?secret=${this.v2secret}&response=${v2Token}` + let response - - let recaptchaBody = { - secret: `${this.v2secret}`, - response: `${v2Token}`, - } - + try { - response = await axios - .get(URL, { - headers: { "Content-Type": "application/x-www-form-urlencoded" }, - params: recaptchaBody, - }) - .then((r: any) => { - return r - }) + response = await axios.post(URL) + .then((r: any) => { + return r + }) } catch (err: any) { - console.log("Recaptcha V2 error:", err?.message) + console.log("Recaptcha V2 error:", err?.message) } - - const data = response?.data + const data = response?.data + console.log("Recaptcha V2 verify response:", data) + if(data?.success) { return true } @@ -47,6 +41,8 @@ export class VerifyCaptcha { } async verifyV3Token(v3Token: string): Promise { + console.log("Recaptcha V3 Token:", v3Token) + const URL = `https://www.google.com/recaptcha/api/siteverify?secret=${this.secret}&response=${v3Token}` let response @@ -57,6 +53,7 @@ export class VerifyCaptcha { } const data = response?.data + console.log("Recaptcha V3 verify response:", data) if(data?.success) { if(data?.action == 'faucetdrip') { @@ -70,6 +67,7 @@ export class VerifyCaptcha { } async shouldAllow(token: string, v2Token: string): Promise { + console.log("Recaptcha tokens:", token, v2Token) if(await this.verifyV3Token(token)) { return true } else { @@ -77,6 +75,7 @@ export class VerifyCaptcha { return true } } + console.log("Recaptcha verification failed!") return false }