mirror of
https://github.com/zoe-may/TDoG-Skin.git
synced 2025-01-19 10:17:24 +08:00
25 lines
454 B
PHP
25 lines
454 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Middleware;
|
||
|
|
||
|
use Closure;
|
||
|
use Illuminate\Http\Request;
|
||
|
|
||
|
class CheckRole
|
||
|
{
|
||
|
protected $roles = [
|
||
|
'banned' => -1,
|
||
|
'normal' => 0,
|
||
|
'admin' => 1,
|
||
|
'super-admin' => 2,
|
||
|
];
|
||
|
|
||
|
public function handle(Request $request, Closure $next, $role)
|
||
|
{
|
||
|
$permission = $request->user()->permission;
|
||
|
abort_if($permission < $this->roles[$role], 403);
|
||
|
|
||
|
return $next($request);
|
||
|
}
|
||
|
}
|