diff --git a/app/resources/routes/01_api.php b/app/resources/routes/01_api.php index a8f19fa..73fb159 100644 --- a/app/resources/routes/01_api.php +++ b/app/resources/routes/01_api.php @@ -10,4 +10,4 @@ $app->group('/api', function($app) { include_once $file->getRealPath(); } } -}); +})->add($app->getContainer()->get(Incoviba\Middleware\API::class)); diff --git a/app/resources/routes/02_inmobiliarias.php b/app/resources/routes/02_inmobiliarias.php index fd29f8d..8991df7 100644 --- a/app/resources/routes/02_inmobiliarias.php +++ b/app/resources/routes/02_inmobiliarias.php @@ -3,4 +3,4 @@ use Incoviba\Controller\Inmobiliarias; $app->group('/inmobiliarias', function($app) { $app->get('[/]', Inmobiliarias::class); -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/routes/03_proyectos.php b/app/resources/routes/03_proyectos.php index 7c734ea..332e7e7 100644 --- a/app/resources/routes/03_proyectos.php +++ b/app/resources/routes/03_proyectos.php @@ -4,7 +4,7 @@ use Incoviba\Controller\Proyectos; $app->group('/proyectos', function($app) { $app->get('/unidades[/]', [Proyectos::class, 'unidades']); $app->get('[/]', Proyectos::class); -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); $app->group('/proyecto/{proyecto_id}', function($app) { $app->get('[/]', [Proyectos::class, 'show']); -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/routes/04_ventas.php b/app/resources/routes/04_ventas.php index 4d41b9f..8e02291 100644 --- a/app/resources/routes/04_ventas.php +++ b/app/resources/routes/04_ventas.php @@ -11,10 +11,10 @@ $app->group('/ventas', function($app) { } $app->get('/add[/]', [Ventas::class, 'add']); $app->get('[/]', Ventas::class); -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); $app->group('/venta/{proyecto_nombre:[A-za-zÑñ\+\ %0-9]+}/{unidad_descripcion:[0-9]+}', function($app) { $app->get('[/]', [Ventas::class, 'showUnidad']); -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); $app->group('/venta/{venta_id:[0-9]+}', function($app) { $app->group('/propietario', function($app) { $app->get('[/]', [Ventas::class, 'propietario']); @@ -29,4 +29,4 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) { }); $app->get('/edit[/]', [Ventas::class, 'edit']); $app->get('[/]', [Ventas::class, 'show']); -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/routes/97_search.php b/app/resources/routes/97_search.php index c76b639..79cd977 100644 --- a/app/resources/routes/97_search.php +++ b/app/resources/routes/97_search.php @@ -4,4 +4,4 @@ use Incoviba\Controller\Search; $app->group('/search', function($app) { $app->get('[/{query}[/{tipo}[/]]]', Search::class); $app->post('[/]', Search::class); -}); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/routes/98_login.php b/app/resources/routes/98_login.php index 4521062..0623659 100644 --- a/app/resources/routes/98_login.php +++ b/app/resources/routes/98_login.php @@ -4,5 +4,5 @@ use Incoviba\Controller\Login; $app->group('/login', function($app) { $app->post('[/]', [Login::class, 'login']); $app->get('[/]', [Login::class, 'form']); -}); -$app->get('/logout', [Login::class, 'logout']); +})->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); +$app->get('/logout', [Login::class, 'logout'])->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/routes/99_base.php b/app/resources/routes/99_base.php index 24b84c0..12e7eb1 100644 --- a/app/resources/routes/99_base.php +++ b/app/resources/routes/99_base.php @@ -2,4 +2,4 @@ use Incoviba\Controller\Base; $app->get('/construccion', [Base::class, 'construccion'])->setName('construccion'); -$app->get('[/]', Base::class); +$app->get('[/]', Base::class)->add($app->getContainer()->get(Incoviba\Middleware\Authentication::class)); diff --git a/app/resources/views/home.blade.php b/app/resources/views/home.blade.php index 134a306..63180f0 100644 --- a/app/resources/views/home.blade.php +++ b/app/resources/views/home.blade.php @@ -28,7 +28,7 @@ return { hoy: () => { const span = $('#cuotas_hoy') - return fetch('{{$urls->api}}/ventas/cuotas/hoy').then(response => { + return fetchAPI('{{$urls->api}}/ventas/cuotas/hoy').then(response => { span.html('') if (response.ok) { return response.json() @@ -48,7 +48,7 @@ }, pendiente: () => { const span = $('#cuotas_pendientes') - return fetch('{{$urls->api}}/ventas/cuotas/pendiente').then(response => { + return fetchAPI('{{$urls->api}}/ventas/cuotas/pendiente').then(response => { span.html('') if (response.ok) { return response.json() diff --git a/app/resources/views/home/alertas.blade.php b/app/resources/views/home/alertas.blade.php index 454cd2b..a1f9378 100644 --- a/app/resources/views/home/alertas.blade.php +++ b/app/resources/views/home/alertas.blade.php @@ -13,7 +13,7 @@ proyectos: () => { this.draw().loading() const url = '{{$urls->api}}/proyectos/escriturando' - return fetch(url).then(response => { + return fetchAPI(url).then(response => { if (response.ok) { return response.json() } @@ -38,7 +38,7 @@ }, unidades: proyecto_id => { const url = '{{$urls->api}}/ventas/unidades/disponibles' - return fetch(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => { + return fetchAPI(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => { if (response.ok) { return response.json() } @@ -49,7 +49,7 @@ }, promesas: proyecto_id => { const url = '{{$urls->api}}/ventas/estados/firmar' - return fetch(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => { + return fetchAPI(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => { if (response.ok) { return response.json() } @@ -60,7 +60,7 @@ }, escrituras: proyecto_id => { const url = '{{$urls->api}}/ventas/escrituras/estados'; - return fetch(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => { + return fetchAPI(url, {method: 'post', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proyecto_id})}).then(response => { if (response.ok) { return response.json() } diff --git a/app/resources/views/home/cierres_vigentes.blade.php b/app/resources/views/home/cierres_vigentes.blade.php index 06f6443..0cf75f2 100644 --- a/app/resources/views/home/cierres_vigentes.blade.php +++ b/app/resources/views/home/cierres_vigentes.blade.php @@ -10,7 +10,7 @@ list.append( $('