Completed
Push — dev ( 39ba5f...0b8cdb )
by Tristan
04:57 queued 04:51
created

VerifyCsrfToken   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 41
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\Middleware;
4
5
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
6
7
class VerifyCsrfToken extends Middleware
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class VerifyCsrfToken
Loading history...
8
{
9
    /**
10
     * Indicates whether the XSRF-TOKEN cookie should be set on the response.
11
     *
12
     * @var bool
13
     */
14
    protected $addHttpCookie = false;
15
16
    /**
17
     * The URIs that should be excluded from CSRF verification.
18
     *
19
     * @var array
20
     */
21
    protected $except = [
22
        //
23
    ];
24
25
26
    /**
27
     * OVERRIDE to make adding XSRF-TOKEN cookie optional
28
     *
29
     * Add the CSRF token to the response cookies.
30
     *
31
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 19 spaces after parameter type; 2 found
Loading history...
32
     * @param  \Symfony\Component\HttpFoundation\Response  $response
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
33
     * @return \Symfony\Component\HttpFoundation\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
34
     */
35
    protected function addCookieToResponse($request, $response)
36
    {
37
        if ($this->addHttpCookie) {
38
            $config = config('session');
39
            $response->headers->setCookie(
40
                new Cookie(
0 ignored issues
show
Bug introduced by
The type App\Http\Middleware\Cookie was not found. Did you mean Cookie? If so, make sure to prefix the type with \.
Loading history...
41
                    'XSRF-TOKEN', $request->session()->token(), $this->availableAt(60 * $config['lifetime']),
42
                    $config['path'], $config['domain'], $config['secure'], false, false, $config['same_site'] ?? null
43
                )
44
            );
45
        }
46
47
        return $response;
48
    }
49
}
50