Created
June 4, 2019 20:48
-
-
Save gugu/701cc09d4c9c7dbc4f05991c1b6dea2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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