| @@ -293,8 +293,21 @@ | ||
| 293 | 293 | 'message' => __('New customer registration is disabled.', 'yatra'), |
| 294 | 294 | ], 403); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | + // reCAPTCHA v3 (no-op unless the registration form is protected in settings). | |
| 298 | + $recaptcha = \Yatra\Services\RecaptchaService::verifyForm( | |
| 299 | + 'registration', | |
| 300 | + (string) ($request->get_param('recaptcha_token') ?? ''), | |
| 301 | + $_SERVER['REMOTE_ADDR'] ?? null | |
| 302 | + ); | |
| 303 | + if (empty($recaptcha['success'])) { | |
| 304 | + return new \WP_REST_Response([ | |
| 305 | + 'success' => false, | |
| 306 | + 'message' => $recaptcha['message'] ?? __('reCAPTCHA verification failed.', 'yatra'), | |
| 307 | + ], 400); | |
| 308 | + } | |
| 309 | + | |
| 297 | 310 | $first_name = sanitize_text_field($request->get_param('first_name') ?? ''); |
| 298 | 311 | $last_name = sanitize_text_field($request->get_param('last_name') ?? ''); |
| 299 | 312 | $email = sanitize_email($request->get_param('email') ?? ''); |
| 300 | 313 | $phone = sanitize_text_field($request->get_param('phone') ?? ''); |