Skip to content

Commit

Permalink
Merge pull request #26 from movementlabsxyz/imola-baku
Browse files Browse the repository at this point in the history
hot fix
  • Loading branch information
0xPrimata authored Jul 30, 2024
2 parents ce54b25 + 12513d3 commit 9b5f41a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/api/captcha.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { NextRequest, NextResponse } from 'next/server';

export const config = {
runtime: 'edge',
};

export default async function handler(req: NextRequest) {
const { recaptchaResponse } = await req.json();

if (!recaptchaResponse) {
return NextResponse.json({ success: false, message: 'No CAPTCHA token provided' }, { status: 400 });
}

const secretKey = process.env.RECAPTCHA_SECRET_KEY;

const verificationResponse = await fetch(`https://www.google.com/recaptcha/api/siteverify`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `secret=${secretKey}&response=${recaptchaResponse}`,
});

const verificationResult = await verificationResponse.json();

if (verificationResult.success) {
// CAPTCHA verified successfully, proceed with your form processing
return NextResponse.json({ success: true });
} else {
return NextResponse.json({ success: false, message: 'CAPTCHA verification failed' }, { status: 400 });
}
}
7 changes: 7 additions & 0 deletions src/components/Chain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export default function Chains({ name,eventName, language, amount, isEvm, networ


setLoading(true);
if (recaptchaRef.current === null) return;
const captchaValue = recaptchaRef?.current.getValue()
if (!captchaValue) {
setErrorMessage("Please complete the captcha.");
setLoading(false);
return;
}
recaptchaRef.current?.reset();

let status = false;
Expand Down

0 comments on commit 9b5f41a

Please sign in to comment.