mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-23 11:08:13 -05: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);
|
||
|
}
|
||
|
}
|