fix
This commit is contained in:
parent
aa3096d6fe
commit
b023f76e9b
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
var_dump($_SERVER['REQUEST_URI']);
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../src/Utils/CorsHandler.php';
|
require_once __DIR__ . '/../src/Utils/CorsHandler.php';
|
||||||
|
|
||||||
|
@ -19,18 +18,21 @@ $method = $_SERVER['REQUEST_METHOD'];
|
||||||
$basePath = '/api_candidatos';
|
$basePath = '/api_candidatos';
|
||||||
$normalizedPath = str_replace($basePath, '', $path);
|
$normalizedPath = str_replace($basePath, '', $path);
|
||||||
|
|
||||||
|
// Enrutamiento
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case preg_match('#^/oauth/token#', $normalizedPath):
|
case preg_match('#^/oauth/token#', $normalizedPath):
|
||||||
echo json_encode(["mensaje" => "Entró en oauth/token"]);
|
require_once __DIR__ . '/../src/Oauth/Routes/AuthRoutes.php';
|
||||||
// require_once __DIR__ . '/../src/Oauth/Routes/AuthRoutes.php';
|
// /../src/candidatos/index.php
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case preg_match('#^/candidatos#', $normalizedPath):
|
case preg_match('#^/candidatos#', $normalizedPath):
|
||||||
echo json_encode(["mensaje" => "Entró en candidatos"]);
|
// Verificar token de OAuth 2.0 antes de acceder a rutas protegidas
|
||||||
// require_once __DIR__ . '/../src/Oauth/Middleware/AuthMiddleware.php';
|
require_once __DIR__ . '/../src/Oauth/Middleware/AuthMiddleware.php';
|
||||||
// if (\OAuth\Middleware\AuthMiddleware::verifyToken()) {
|
|
||||||
// require_once __DIR__ . '/../src/candidatos/index.php';
|
// Solo continuamos si el token es válido
|
||||||
// }
|
if (\OAuth\Middleware\AuthMiddleware::verifyToken()) {
|
||||||
|
require_once __DIR__ . '/../src/candidatos/index.php';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -38,5 +40,4 @@ switch (true) {
|
||||||
echo json_encode(["error" => "Ruta no encontrada"]);
|
echo json_encode(["error" => "Ruta no encontrada"]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue