Created
October 30, 2022 18:25
-
-
Save ydenissov/fb60363d7b0b83faca7031eb50b96447 to your computer and use it in GitHub Desktop.
Middleware for check user Active
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Add in Http\Kernel.php after protected $routeMiddleware -> 'isActive' => \App\Http\Middleware\CheckUserActive::class, */ | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Support\Facades\Lang; | |
use Illuminate\Support\Facades\Auth; | |
class CheckUserActive | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
if (Auth::check()) { | |
if ($request->user()->blocked === 1) { | |
Auth::logout(); | |
return redirect()->to('login')->withErrors(Lang::get('auth.blocked')); | |
} | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment