diff --git a/app/Http/Controllers/ComprasController.php b/app/Http/Controllers/ComprasController.php index ae4de0e..0104a7e 100644 --- a/app/Http/Controllers/ComprasController.php +++ b/app/Http/Controllers/ComprasController.php @@ -11,4 +11,9 @@ class ComprasController $file = resource_path('csv/exports/total-pedidos.csv'); return response()->download($file); } + + public function showLoginForm() + { + return view('auth/compras_login'); + } } diff --git a/app/Http/Middleware/Compras.php b/app/Http/Middleware/Compras.php index 8852113..d3a81ad 100644 --- a/app/Http/Middleware/Compras.php +++ b/app/Http/Middleware/Compras.php @@ -3,21 +3,24 @@ namespace App\Http\Middleware; use Closure; -use Auth; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; class Compras { /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param Request $request + * @param Closure $next * @return mixed */ - public function handle($request, Closure $next) + public function handle(Request $request, Closure $next) { - $user = Auth::user(); - if ($user->is_compras) { + if (!Auth::check()) + return redirect()->route('compras.login'); + + if (Auth::user()->is_compras) { return $next($request); } else { return response('Necesitás ser de comisión compras para hacer esto', 403); diff --git a/resources/views/auth/compras_login.blade.php b/resources/views/auth/compras_login.blade.php new file mode 100644 index 0000000..c76f045 --- /dev/null +++ b/resources/views/auth/compras_login.blade.php @@ -0,0 +1,32 @@ + + + + + + {{ config('app.name', 'Pedidos del MPS') }} + + + + + +
+
+

+ Pedidos MPS +

+

+ Bienvenidx a la sección de compras de la aplicación del Mercado Popular de Subsistencia +

+ @error('name') +
+ Contraseña incorrecta, intentalo nuevamente. +
+ @enderror +
+ @csrf +
+
+
+ + + diff --git a/routes/web.php b/routes/web.php index f427bf9..147ffc0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -76,6 +76,8 @@ Route::middleware('auth')->group( function() { }); }); -Route::middleware(['auth', 'compras'])->group( function() { +Route::get('/compras/login', 'ComprasController@showLoginForm')->name('compras.login'); + +Route::middleware(['compras'])->group( function() { Route::get('/compras/pedidos', 'ComprasController@pedidos')->name('compras.pedidos'); });