| Conditions | 5 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function handle(Request $request, Closure $next) |
||
| 18 | { |
||
| 19 | $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN'); |
||
| 20 | $action = $request->wpb_nonce ?: 'wpb_nonce'; |
||
| 21 | |||
| 22 | if ( !wp_verify_nonce( $token, $action ) ) { |
||
|
|
|||
| 23 | if ($request->ajax()) { |
||
| 24 | return wp_send_json(["message" => "CSRF Token mitchmatch"], 403 ); |
||
| 25 | } |
||
| 26 | |||
| 27 | throw new \Exception("CSRF Token mismatch"); |
||
| 28 | |||
| 29 | |||
| 30 | } |
||
| 31 | |||
| 32 | return $next($request); |
||
| 33 | } |
||
| 35 |