mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-25 17:54:57 +01:00
27 lines
514 B
PHP
27 lines
514 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Auth\Access\AuthorizationException;
|
|
|
|
class AdminOnly
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
if (! Auth::user()->is_admin) {
|
|
throw new AuthorizationException;
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|