mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
30 lines
729 B
PHP
30 lines
729 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Services\AuthService;
|
|
use Closure;
|
|
|
|
class Staff
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$authorization = $request->input('auth_data') ?? $request->header('authorization');
|
|
if (!$authorization) abort(403, '未登录或登陆已过期');
|
|
|
|
$user = AuthService::decryptAuthData($authorization);
|
|
if (!$user || !$user['is_staff']) abort(403, '未登录或登陆已过期');
|
|
$request->merge([
|
|
'user' => $user
|
|
]);
|
|
return $next($request);
|
|
}
|
|
}
|