feat: new xboard

This commit is contained in:
xboard
2025-01-21 14:57:54 +08:00
parent de18cfe596
commit 0f43fff242
373 changed files with 17923 additions and 20264 deletions
+9 -9
View File
@@ -3,9 +3,8 @@
namespace App\Http\Middleware;
use App\Exceptions\ApiException;
use App\Services\AuthService;
use Illuminate\Support\Facades\Auth;
use Closure;
use Illuminate\Support\Facades\Cache;
class Admin
{
@@ -18,14 +17,15 @@ class Admin
*/
public function handle($request, Closure $next)
{
$authorization = $request->input('auth_data') ?? $request->header('authorization');
if (!$authorization) throw new ApiException('未登录或登陆已过期', 403);
if (!Auth::guard('sanctum')->check()) {
throw new ApiException('未登录或登陆已过期', 403);
}
$user = Auth::guard('sanctum')->user();
if (!$user->is_admin) {
throw new ApiException('无管理员权限', 403);
}
$user = AuthService::decryptAuthData($authorization);
if (!$user || !$user['is_admin']) throw new ApiException('未登录或登陆已过期',403);
$request->merge([
'user' => $user
]);
return $next($request);
}
}