Selaa lähdekoodia

增加安全中间件

sunxbiao 7 kuukautta sitten
vanhempi
commit
3ace0c44a1
1 muutettua tiedostoa jossa 20 lisäystä ja 18 poistoa
  1. 20 18
      app/middleware/SecurityMiddleware.php

+ 20 - 18
app/middleware/SecurityMiddleware.php

@@ -449,17 +449,18 @@ class SecurityMiddleware
449 449
      */
450 450
     protected function blockResponse(): Response
451 451
     {
452
-        return response()
453
-            ->json([
454
-                'code' => 403,
455
-                'message' => '访问被拒绝',
456
-                'data' => null
457
-            ])
458
-            ->code(403)
459
-            ->header([
460
-                'Content-Type' => 'application/json',
461
-                'Retry-After' => 3600
462
-            ]);
452
+        throw new \Exception('访问被拒绝', 403);
453
+        // return response()
454
+        //     ->json([
455
+        //         'code' => 403,
456
+        //         'message' => '访问被拒绝',
457
+        //         'data' => null
458
+        //     ])
459
+        //     ->code(403)
460
+        //     ->header([
461
+        //         'Content-Type' => 'application/json',
462
+        //         'Retry-After' => 3600
463
+        //     ]);
463 464
     }
464 465
 
465 466
     /**
@@ -467,12 +468,13 @@ class SecurityMiddleware
467 468
      */
468 469
     protected function errorResponse(): Response
469 470
     {
470
-        return response()
471
-            ->json([
472
-                'code' => 400,
473
-                'message' => '请求参数错误',
474
-                'data' => null
475
-            ])
476
-            ->code(400);
471
+        throw new \Exception('请求参数错误', 400);
472
+        // return response()
473
+        //     ->json([
474
+        //         'code' => 400,
475
+        //         'message' => '请求参数错误',
476
+        //         'data' => null
477
+        //     ])
478
+        //     ->code(400);
477 479
     }
478 480
 }