Skip to content

Commit

Permalink
Don't validate captcha in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed May 21, 2024
1 parent 206cf6e commit a6c7d55
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions packages/next-drupal/src/config/Validations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,7 @@ const emailValidation = ({ name, required }) => {
}

const friendlycaptchaValidation = () => {
return yup
.string()
.test('captcha', 'Captcha verification is invalid', async (solution) => {
if (process.env.NODE_ENV === 'development') {
return true
}
const body = new FormData()
body.append(
'secret',
process.env.NEXT_PUBLIC_FRIENDLYCAPTCHA_SECRET || '',
)
body.append(
'sitekey',
process.env.NEXT_PUBLIC_FRIENDLYCAPTCHA_SITEKEY || '',
)
body.append('solution', solution || '')

try {
const response = await fetch(
'https://api.friendlycaptcha.com/api/v1/siteverify',
{
body,
headers: {
'Content-Type': 'application/json',
},
method: 'POST',
},
)
const result: any = await response.text()
if (result?.success) {
return true
}
return false
} catch (e) {
return false
}
})
.required('Captcha verification is required')
return yup.string().required('Captcha verification is required')
}

// Validations mapping
Expand Down

0 comments on commit a6c7d55

Please sign in to comment.