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:
@@ -3,6 +3,7 @@
|
||||
namespace routes;
|
||||
|
||||
use classes\authentication;
|
||||
use classes\recaptcha;
|
||||
use objects\logs_o;
|
||||
use objects\tokens_o;
|
||||
use traits\route_t;
|
||||
@@ -16,6 +17,7 @@ class authRoute
|
||||
$this->post('/auth/login', function () {
|
||||
// Get the post data
|
||||
global $response;
|
||||
$this->requireRecaptcha();
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
// Check if the customer number, and password are set
|
||||
if (!isset($data['customer_number']) || empty($data['customer_number']) || !is_numeric($data['customer_number']) || $data['customer_number'] < 1) {
|
||||
@@ -80,6 +82,7 @@ class authRoute
|
||||
$this->post('/auth/employee/login', function () {
|
||||
// Get the post data
|
||||
global $response;
|
||||
$this->requireRecaptcha();
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
// Check if the employee number, and password are set
|
||||
if (!isset($data['user_id'])) {
|
||||
@@ -102,5 +105,23 @@ class authRoute
|
||||
// Return the token
|
||||
$response->success(['token' => $token]);
|
||||
});
|
||||
|
||||
$this->get('/auth/reCAPTCHA/public', function () {
|
||||
// Check if the user:
|
||||
// 1. Is rate limited (future feature)
|
||||
// 2. Is required to solve a reCAPTCHA
|
||||
global $response;
|
||||
$recaptcha = (new recaptcha())->getPublicConfig();
|
||||
$response->success([
|
||||
'rate_limit' => [
|
||||
'enabled' => false,
|
||||
'limit' => 0,
|
||||
'remaining' => 0,
|
||||
'reset' => 0,
|
||||
'warning' => null
|
||||
],
|
||||
'recaptcha' => $recaptcha
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user