Added ActiveUser middleware

This commit is contained in:
Deon George 2024-07-23 00:11:06 +10:00
parent 12496101e1
commit b9a3cd5647

View File

@ -0,0 +1,26 @@
<?php
namespace Leenooks\Http\Middleware;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ActiveUser
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request,\Closure $next)
{
if ((! Auth::user()?->exists) || (! Auth::user()->active)) {
Auth::logout();
abort(403,'Your account is not active');
}
return $next($request);
}
}