Loading app/Http/Middleware/CheckBanned.php 0 → 100644 +29 −0 Original line number Diff line number Diff line <?php namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Symfony\Component\HttpFoundation\Response; class CheckBanned { /** * Handle an incoming request. * * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next */ public function handle(Request $request, Closure $next): Response { //dd(Auth()); if(auth()->check() && (auth()->user()->active == 0)){ auth('web')->logout(); $request->session()->invalidate(); $request->session()->regenerateToken(); return redirect()->route('login')->withErrors('Su cuenta está suspendida, póngase en contacto con el administrador del sistema.'); } return $next($request); } } bootstrap/app.php +3 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; use App\Http\Middleware\CheckBanned; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', Loading @@ -12,7 +14,7 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { // $middleware->append(CheckBanned::class); }) ->withExceptions(function (Exceptions $exceptions) { // Loading routes/web.php +2 −0 Original line number Diff line number Diff line <?php use Illuminate\Support\Facades\Route; use App\Http\Middleware\CheckBanned; Route::get('/', function () { return view('welcome'); Loading @@ -10,6 +11,7 @@ 'auth:sanctum', config('jetstream.auth_session'), 'verified', CheckBanned::class ])->group(function () { Route::get('/dashboard', function () { return view('dashboard'); Loading Loading
app/Http/Middleware/CheckBanned.php 0 → 100644 +29 −0 Original line number Diff line number Diff line <?php namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Symfony\Component\HttpFoundation\Response; class CheckBanned { /** * Handle an incoming request. * * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next */ public function handle(Request $request, Closure $next): Response { //dd(Auth()); if(auth()->check() && (auth()->user()->active == 0)){ auth('web')->logout(); $request->session()->invalidate(); $request->session()->regenerateToken(); return redirect()->route('login')->withErrors('Su cuenta está suspendida, póngase en contacto con el administrador del sistema.'); } return $next($request); } }
bootstrap/app.php +3 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; use App\Http\Middleware\CheckBanned; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', Loading @@ -12,7 +14,7 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { // $middleware->append(CheckBanned::class); }) ->withExceptions(function (Exceptions $exceptions) { // Loading
routes/web.php +2 −0 Original line number Diff line number Diff line <?php use Illuminate\Support\Facades\Route; use App\Http\Middleware\CheckBanned; Route::get('/', function () { return view('welcome'); Loading @@ -10,6 +11,7 @@ 'auth:sanctum', config('jetstream.auth_session'), 'verified', CheckBanned::class ])->group(function () { Route::get('/dashboard', function () { return view('dashboard'); Loading