Compare commits
2 Commits
9259248caf
...
bf3f697299
Author | SHA1 | Date |
---|---|---|
Alejandro Tasistro | bf3f697299 | |
Alejandro Tasistro | 53691f6a30 |
|
@ -11,4 +11,9 @@ class ComprasController
|
||||||
$file = resource_path('csv/exports/total-pedidos.csv');
|
$file = resource_path('csv/exports/total-pedidos.csv');
|
||||||
return response()->download($file);
|
return response()->download($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showLoginForm()
|
||||||
|
{
|
||||||
|
return view('auth/compras_login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ class Kernel extends HttpKernel
|
||||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
\App\Http\Middleware\Compras::class,
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
|
@ -58,6 +57,7 @@ class Kernel extends HttpKernel
|
||||||
protected $routeMiddleware = [
|
protected $routeMiddleware = [
|
||||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
'admin' => \App\Http\Middleware\Admin::class,
|
'admin' => \App\Http\Middleware\Admin::class,
|
||||||
|
'compras' => \App\Http\Middleware\Compras::class,
|
||||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
|
|
|
@ -3,21 +3,24 @@
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Auth;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class Compras
|
class Compras
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param Request $request
|
||||||
* @param \Closure $next
|
* @param Closure $next
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
if (!Auth::check())
|
||||||
if ($user->is_compras) {
|
return redirect()->route('compras.login');
|
||||||
|
|
||||||
|
if (Auth::user()->is_compras) {
|
||||||
return $next($request);
|
return $next($request);
|
||||||
} else {
|
} else {
|
||||||
return response('Necesitás ser de comisión compras para hacer esto', 403);
|
return response('Necesitás ser de comisión compras para hacer esto', 403);
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!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>
|
|
@ -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');
|
Route::get('/compras/pedidos', 'ComprasController@pedidos')->name('compras.pedidos');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue