Add reCAPTCHA support and enhance Economic configurations

Introduce reCAPTCHA integration with validation and configuration handling. Update Economic module to include layout management and dynamic configuration via API. Added traits for managing module settings and encapsulated new endpoint routes for expanded functionality.
This commit is contained in:
Jepp9350
2025-02-10 15:27:32 +01:00
parent ac657d6130
commit 172e37d3a2
19 changed files with 979 additions and 13 deletions
+22
View File
@@ -3,6 +3,7 @@
namespace traits;
use classes\authentication;
use classes\recaptcha;
use objects\logs_o;
trait route_t
@@ -138,6 +139,27 @@ trait route_t
return true;
}
/**
* Require reCAPTCHA for the request
* @return bool
*/
public function requireRecaptcha(): bool
{
global $response;
// Check if the reCAPTCHA is valid
try {
$recaptcha_response = $response->getRequestParameter('g_recaptcha_response');
$recaptcha = (new recaptcha())->validate($recaptcha_response);
if (!$recaptcha) {
(new logs_o())->add('global', 'global', 1, 0, 'AUTHENTICATION_FAILED', 'Authentication failed. Invalid, or missing reCAPTCHA');
$response->error('Authentication failed. Invalid or missing reCAPTCHA.', 401);
}
} catch (\Exception $e) {
$response->error($e->getMessage(), 400);
}
return true;
}
/**
* Get data from the request body or query string by name
* @param string $name