Skip to content

Instantly share code, notes, and snippets.

@gugu
Created June 4, 2019 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gugu/701cc09d4c9c7dbc4f05991c1b6dea2b to your computer and use it in GitHub Desktop.
Save gugu/701cc09d4c9c7dbc4f05991c1b6dea2b to your computer and use it in GitHub Desktop.
export async function verifyCaptcha(captchaToken: string) {
try {
const verifyResponse = await got.post('https://www.google.com/recaptcha/api/siteverify', {
body: {
response: captchaToken,
secret: process.env.RECAPTCHA_SECRET,
},
form: true,
json: true,
});
return verifyResponse.body;
} catch (e) {
// If recaptcha is down, we should not fail
Raven.captureException(e);
return {
success: true,
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment