Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | public function handle(Request $request, Closure $next) |
||
34 | { |
||
35 | $token = $request->input('_token') ?? $request->header('X-CSRF-TOKEN'); |
||
36 | $action = $request->wpb_nonce ?? 'wpb_nonce'; |
||
37 | |||
38 | if (!wp_verify_nonce($token, $action)) { |
||
|
|||
39 | if ($request->ajax()) { |
||
40 | return wp_send_json(['message' => 'CSRF Token mitchmatch'], 403); |
||
41 | } |
||
42 | |||
43 | throw new \Exception('CSRF Token mismatch'); |
||
44 | } |
||
45 | |||
46 | return $next($request); |
||
47 | } |
||
49 |