Add JSON endpoint for CAPTCHA rendering

To be used inside WP/WC registration form to construct URL for CAPTCHA page.

[MAILPOET-6325]
This commit is contained in:
Mustapha Hadid
2024-11-15 21:50:45 +03:00
committed by David Remer
parent d2ebfba8c3
commit df171fdcc7
7 changed files with 101 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
namespace MailPoet\API\JSON;
use MailPoet\API\JSON\v1\RedirectResponse;
use MailPoet\Config\AccessControl;
abstract class Endpoint {
@@ -41,6 +42,10 @@ abstract class Endpoint {
return new ErrorResponse($errors, $meta, Response::STATUS_BAD_REQUEST);
}
public function redirectResponse($url) {
return new RedirectResponse($url);
}
public function isMethodAllowed($name, $type) {
// Block GET requests on POST endpoints, but allow POST requests on GET endpoints (some plugins
// change REQUEST_METHOD to POST on GET requests, which caused them to be blocked)