Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function onKernelRequest(GetResponseEvent $event) |
||
20 | { |
||
21 | $request = $event->getRequest(); |
||
22 | if (false === $request->attributes->get('_check_csrf', false)) { |
||
23 | return; |
||
24 | } |
||
25 | if (!$request->request->has('_link_token')) { |
||
26 | throw new \InvalidArgumentException( |
||
27 | 'The CSRF token verification is activated but you did not send a token. Please submit a request with a valid csrf token.' |
||
28 | ); |
||
29 | } |
||
30 | |||
31 | $token = $request->request->get('_link_token'); |
||
32 | |||
33 | if (!$this->csrfProvider->isCsrfTokenValid($this->intention, $token)) { |
||
34 | throw new \InvalidArgumentException( |
||
35 | 'The CSRF token is invalid. Please submit a request with a valid csrf token.' |
||
36 | ); |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 |