Compare commits

..

No commits in common. "bf3f6972991f2170acc2eaa1abaebbb704d7c699" and "9259248caf28c7508c43d50b148aaba5f9d3ff0f" have entirely different histories.

5 changed files with 8 additions and 50 deletions

View File

@ -11,9 +11,4 @@ class ComprasController
$file = resource_path('csv/exports/total-pedidos.csv');
return response()->download($file);
}
public function showLoginForm()
{
return view('auth/compras_login');
}
}

View File

@ -38,6 +38,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\Compras::class,
],
'api' => [
@ -57,7 +58,6 @@ class Kernel extends HttpKernel
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'admin' => \App\Http\Middleware\Admin::class,
'compras' => \App\Http\Middleware\Compras::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,

View File

@ -3,24 +3,21 @@
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Auth;
class Compras
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
public function handle($request, Closure $next)
{
if (!Auth::check())
return redirect()->route('compras.login');
if (Auth::user()->is_compras) {
$user = Auth::user();
if ($user->is_compras) {
return $next($request);
} else {
return response('Necesitás ser de comisión compras para hacer esto', 403);

View File

@ -1,32 +0,0 @@
<!DOCTYPE html>
<html class="has-background-warning" lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ config('app.name', 'Pedidos del MPS') }}</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
<script src="https://kit.fontawesome.com/9235d1c676.js" crossorigin="anonymous"></script>
</head>
<body>
<section class="section">
<div id="root" class="container">
<h1 class="title">
Pedidos MPS
</h1>
<p class="subtitle">
Bienvenidx a la sección de compras de la aplicación del <strong>Mercado Popular de Subsistencia</strong>
</p>
@error('name')
<div class="notification is-danger">
Contraseña incorrecta, intentalo nuevamente.
</div>
@enderror
<form method="post" action="login">
@csrf
</form>
</div>
</section>
<script src="{{ mix('js/app.js') }}" defer></script>
</body>
</html>

View File

@ -76,8 +76,6 @@ Route::middleware('auth')->group( function() {
});
});
Route::get('/compras/login', 'ComprasController@showLoginForm')->name('compras.login');
Route::middleware(['compras'])->group( function() {
Route::middleware(['auth', 'compras'])->group( function() {
Route::get('/compras/pedidos', 'ComprasController@pedidos')->name('compras.pedidos');
});