Add reCAPTCHA support and update captcha provider handling (#647)

* Add reCAPTCHA support and update captcha provider handling

- Introduced reCAPTCHA as an additional captcha provider alongside hCaptcha.
- Updated form request validation to handle different captcha providers based on user selection.
- Added a new validation rule for reCAPTCHA.
- Modified the forms model to include a 'captcha_provider' field.
- Created a migration to add the 'captcha_provider' column to the forms table.
- Updated frontend components to support dynamic rendering of captcha based on the selected provider.
- Enhanced tests to cover scenarios for both hCaptcha and reCAPTCHA.

These changes improve the flexibility of captcha options available to users, enhancing form security and user experience.

* fix pint

* change comment text

* Refactor captcha implementation and integrate new captcha components

- Removed the old RecaptchaV2 component and replaced it with a new implementation that supports both reCAPTCHA and hCaptcha through a unified CaptchaInput component.
- Updated the OpenForm component to utilize the new CaptchaInput for dynamic captcha rendering based on user-selected provider.
- Cleaned up the package.json by removing the deprecated @hcaptcha/vue3-hcaptcha dependency.
- Enhanced form initialization to set a default captcha provider.
- Improved error handling and cleanup for both reCAPTCHA and hCaptcha scripts.

These changes streamline captcha integration, improve maintainability, and enhance user experience by providing a more flexible captcha solution.

* Refactor captcha error messages and localization support

* Refactor registration process to integrate reCAPTCHA

- Replaced hCaptcha implementation with reCAPTCHA in RegisterController and related test cases.
- Updated validation rules to utilize g-recaptcha-response instead of h-captcha-response.
- Modified RegisterForm component to support reCAPTCHA, including changes to the form data structure and component references.
- Enhanced test cases to reflect the new reCAPTCHA integration, ensuring proper validation and response handling.

These changes improve security and user experience during the registration process by adopting a more widely used captcha solution.

* Fix reCAPTCHA configuration and update RegisterForm styling

- Corrected the configuration key for reCAPTCHA in RegisterController from 'services.recaptcha.secret_key' to 'services.re_captcha.secret_key'.
- Updated the styling of the Captcha input section in RegisterForm.vue to improve layout consistency.

These changes ensure proper reCAPTCHA functionality and enhance the user interface during the registration process.

* Fix reCAPTCHA configuration in RegisterTest to use the correct key format

- Updated the configuration key for reCAPTCHA in RegisterTest from 'services.recaptcha.secret_key' to 'services.re_captcha.secret_key' to ensure proper functionality during tests.

This change aligns the test setup with the recent updates in the reCAPTCHA integration, improving the accuracy of the registration process tests.

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala
2024-12-18 21:05:09 +05:30
committed by GitHub
parent 7365479c83
commit d7ce8536c8
43 changed files with 770 additions and 97 deletions

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'إدخال غير صالح. يرجى التصحيح والمحاولة مرة أخرى.',
'invalid_captcha' => 'التحقق من صحة الحقل غير صحيح. يرجى التحقق من صحة الحقل والمحاولة مرة أخرى.',
'complete_captcha' => 'يرجى إكمال التحقق من صحة الحقل.',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'অবৈধ ইনপুট। অনুগ্রহ করে সংশোধন করে আবার চেষ্টা করুন।',
'invalid_captcha' => 'অবৈধ টিপস। অনুগ্রহ করে টিপস টিপুন।',
'complete_captcha' => 'অনুগ্রহ করে টিপস টিপুন।',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'Ungültige Eingabe. Bitte korrigieren Sie und versuchen Sie es erneut.',
'invalid_captcha' => 'Ungültige CAPTCHA. Bitte beweisen Sie, dass Sie kein Bot sind.',
'complete_captcha' => 'Bitte füllen Sie die CAPTCHA aus.',
];

View File

@@ -150,5 +150,7 @@ return [
'attributes' => [],
'invalid_json' => 'Invalid input. Please correct and try again.',
'invalid_captcha' => 'Invalid CAPTCHA. Please prove you\'re not a bot.',
'complete_captcha' => 'Please complete the captcha.',
];

View File

@@ -153,5 +153,7 @@ return [
],
'invalid_json' => 'Entrada no válida. Por favor, corrija e intente nuevamente.',
'invalid_captcha' => 'Captcha no válido. Por favor, demuestre que no es un bot.',
'complete_captcha' => 'Por favor, complete el captcha.',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'Entrée invalide. Veuillez corriger et réessayer.',
'invalid_captcha' => 'Captcha invalide. Veuillez prouver que vous n\'êtes pas un bot.',
'complete_captcha' => 'Veuillez compléter le captcha.',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'अमान्य इनपुट। कृपया सुधारें और पुनः प्रयास करें।',
'invalid_captcha' => 'अमान्य कैप्चा। कृपया दिखाएं कि आप एक बॉट नहीं हैं।',
'complete_captcha' => 'कृपया कैप्चा भरें।',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => '無効な入力です。修正して再度お試しください。',
'invalid_captcha' => '無効なCAPTCHAです。ボットではないことを証明してください。',
'complete_captcha' => 'CAPTCHAを完了してください。',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'Input ora valid. Mangga dibenakake lan dicoba maneh.',
'invalid_captcha' => 'CAPTCHA ora valid. Mangga dibenakake lan dicoba maneh.',
'complete_captcha' => 'CAPTCHA kudu diisi.',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => '잘못된 입력입니다. 수정 후 다시 시도해 주세요.',
'invalid_captcha' => '잘못된 캡차입니다. 봇이 아님을 증명해 주세요.',
'complete_captcha' => '캡차를 완료해 주세요.',
];

View File

@@ -133,4 +133,6 @@ return [
'attributes' => [],
'invalid_json' => 'अवैध इनपुट. कृपया सुधारून पुन्हा प्रयत्न करा.',
'invalid_captcha' => 'अवैध कैप्चा। कृपया कैप्चा टिपला आणि पुन्हा प्रयत्न करा।',
'complete_captcha' => 'कृपया कैप्चा भरा.',
];

View File

@@ -115,5 +115,7 @@ return [
'attributes' => [],
'invalid_json' => 'ਗਲਤ ਇਨਪੁਟ। ਕਿਰਪਾ ਕਰਕੇ ਸਹੀ ਕਰੋ ਅਤੇ ਦੁਬਾਰਾ ਕੋਸ਼ਿਸ਼ ਕਰੋ।',
'invalid_json' => 'ਗਲਤ ਇਨਪੁਟ। ਕਿਰਪਾ ਕਰਕੇ ਸਹੀ ਕਰੋ ਅਤੇ ਦੁਬਾਰਾ ਕੋਸ਼ਿਸ਼ ਕਰੋ।',
'invalid_captcha' => 'ਗਲਤ ਕੈਪਚਾ। ਕਿਰਪਾ ਕਰੋ ਕੈਪਚਾ ਟੀਪ ਅਤੇ ਦੁਬਾਰਾ ਕੋਸ਼ਿਸ਼ ਕਰੋ।',
'complete_captcha' => 'ਕਿਰਪਾ ਕਰੋ ਕੈਪਚਾ ਭਰੋ।',
];

View File

@@ -180,4 +180,6 @@ return [
],
'invalid_json' => 'Entrada inválida. Por favor, corrija e tente novamente.',
'invalid_captcha' => 'Captcha inválido. Por favor, demonstre que não é um bot.',
'complete_captcha' => 'Por favor, complete o captcha.',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'Entrada inválida. Por favor, corrija e tente novamente.',
'invalid_captcha' => 'Captcha inválido. Por favor, demonstre que não é um bot.',
'complete_captcha' => 'Por favor, complete o captcha.',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'Неверный ввод. Пожалуйста, исправьте и попробуйте снова.',
'invalid_captcha' => 'Неверный CAPTCHA. Пожалуйста, докажите, что вы не бот.',
'complete_captcha' => 'Пожалуйста, заполните CAPTCHA.',
];

View File

@@ -133,4 +133,6 @@ return [
'attributes' => [],
'invalid_json' => 'தவறான உள்ளீடு. சரிசெய்து மீண்டும் முயற்சிக்கவும்.',
'invalid_captcha' => 'தவறான கையால் வைத்த முறை. மீண்டும் முயற்சிக்கவும்.',
'complete_captcha' => 'கையால் வைத்த முறையை நிரப்பவும்.',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'చెల్లని ఇన్‌పుట్. దయచేసి సరిచేసి మళ్లీ ప్రయత్నించండి.',
'invalid_captcha' => 'అవైధ క్యాప్చా. దయచేసి క్యాప్చా టైప్ మరియు మళ్లీ ప్రయత్నించండి.',
'complete_captcha' => 'దయచేసి క్యాప్చా భరించండి.',
];

View File

@@ -133,4 +133,6 @@ return [
'attributes' => [],
'invalid_json' => 'Geçersiz girdi. Lütfen düzeltin ve tekrar deneyin.',
'invalid_captcha' => 'Geçersiz CAPTCHA. Lütfen bot olmadığınızı gösterin.',
'complete_captcha' => 'Lütfen CAPTCHA\'yı tamamlayın.',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'غلط ان پٹ۔ براہ کرم درست کریں اور دوبارہ کوشش کریں۔',
'invalid_captcha' => 'غلط کپچا۔ براہ کرم کپچا ٹائپ کریں اور دوبارہ کوشش کریں۔',
'complete_captcha' => 'براہ کرم کپچا پر کام کریں۔',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => 'Dữ liệu không hợp lệ. Vui lòng sửa và thử lại.',
'invalid_captcha' => 'Mã bảo vệ không đúng. Vui lòng nhập lại và thử lại.',
'complete_captcha' => 'Vui lòng nhập mã bảo vệ.',
];

View File

@@ -96,4 +96,6 @@ return [
'attributes' => [],
'invalid_json' => '输入无效。请修正后重试。',
'invalid_captcha' => '验证码错误。请重新输入并重试。',
'complete_captcha' => '请完成验证码。',
];

View File

@@ -116,4 +116,6 @@ return [
'attributes' => [],
'invalid_json' => '输入无效。请修正后重试。',
'invalid_captcha' => '验证码错误。请重新输入并重试。',
'complete_captcha' => '请完成验证码。',
];