From 3f34483fd560d88a9f8910c8c269788ce9af2997 Mon Sep 17 00:00:00 2001 From: Ale Date: Fri, 14 Oct 2022 17:36:49 -0300 Subject: [PATCH] Agregado middleware autorizacion admin --- app/Http/Kernel.php | 1 + app/Http/Middleware/Admin.php | 26 +++++++++++++++++++++++ public/js/app.js | 39 +++++++++++++++++++++++++++++++---- routes/web.php | 11 +++++----- 4 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 app/Http/Middleware/Admin.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 0ea5972..62c91ee 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -56,6 +56,7 @@ class Kernel extends HttpKernel */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, + 'admin' => \App\Http\Middleware\Admin::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, diff --git a/app/Http/Middleware/Admin.php b/app/Http/Middleware/Admin.php new file mode 100644 index 0000000..6eed291 --- /dev/null +++ b/app/Http/Middleware/Admin.php @@ -0,0 +1,26 @@ +is_admin) { + return $next($request); + } else { + return response('Necesitás ser admin para hacer esto', 403); + } + } +} diff --git a/public/js/app.js b/public/js/app.js index 4e9569c..49e131a 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -2974,6 +2974,14 @@ __webpack_require__.r(__webpack_exports__); // // // +// +// +// +// +// +// +// +// /* harmony default export */ __webpack_exports__["default"] = ({ name: "SubpedidosGdc", @@ -5940,6 +5948,21 @@ var render = function () { }, [ _c("div", { staticClass: "buttons is-right" }, [ + _c( + "a", + { + staticClass: "button is-success", + attrs: { href: "/admin/exportar-pedido-a-csv/" + _vm.gdc }, + }, + [ + _c("span", [ + _vm._v("\n Exportar pedido barrial\n "), + ]), + _vm._v(" "), + _vm._m(0), + ] + ), + _vm._v(" "), _c( "a", { @@ -5951,7 +5974,7 @@ var render = function () { _vm._v("\n Imprimir Planillas\n "), ]), _vm._v(" "), - _vm._m(0), + _vm._m(1), ] ), ]), @@ -5970,7 +5993,7 @@ var render = function () { staticClass: "table is-fullwidth is-striped is-bordered", }, [ - _vm._m(1), + _vm._m(2), _vm._v(" "), _c("tfoot", [ _c("tr", [ @@ -6018,6 +6041,14 @@ var render = function () { ) } var staticRenderFns = [ + function () { + var _vm = this + var _h = _vm.$createElement + var _c = _vm._self._c || _h + return _c("span", { staticClass: "icon is-small" }, [ + _c("i", { staticClass: "fas fa-download" }), + ]) + }, function () { var _vm = this var _h = _vm.$createElement @@ -19560,8 +19591,8 @@ __webpack_require__.r(__webpack_exports__); /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(/*! /home/ale/MPS/App/pedi2/resources/js/app.js */"./resources/js/app.js"); -module.exports = __webpack_require__(/*! /home/ale/MPS/App/pedi2/resources/sass/app.scss */"./resources/sass/app.scss"); +__webpack_require__(/*! /var/www/resources/js/app.js */"./resources/js/app.js"); +module.exports = __webpack_require__(/*! /var/www/resources/sass/app.scss */"./resources/sass/app.scss"); /***/ }) diff --git a/routes/web.php b/routes/web.php index ec3dc89..a3bc085 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,8 +25,6 @@ Route::get('/productos', 'ProductoController@index')->name('productos.index'); Route::get('/admin', 'AdminController@show')->name('admin_login.show'); -Route::get('/admin/pedidos', 'AdminController@index')->name('admin_login.index'); - Route::get('/admin/obtener_sesion', function() { $sesion = [ 'gdc' => session("admin_gdc") @@ -34,11 +32,12 @@ Route::get('/admin/obtener_sesion', function() { return $sesion; })->name('admin_obtener_sesion'); -Route::get('/admin/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPlanillasAPdf'); -Route::get('/admin/exportar-pedido-a-csv/{gdc}', 'AdminController@exportarPedidoACSV'); - Route::middleware(['auth', 'admin'])->group( function () { - //Route::get('/admin/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPlanillasAPdf'); + Route::get('/admin/pedidos', 'AdminController@index')->name('admin_login.index'); + + Route::get('/admin/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPlanillasAPdf'); + + Route::get('/admin/exportar-pedido-a-csv/{gdc}', 'AdminController@exportarPedidoACSV'); }); Route::middleware('auth')->group( function() {