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 @@ + + +
+ + ++ Bienvenidx a la sección de compras de la aplicación del Mercado Popular de Subsistencia +
+ @error('name') +