Authenticate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 14
rs 10
1
<?php
2
declare(strict_types=1);
3
4
5
/**
6
 * Authenticate.php
7
 * Copyright (c) 2020 [email protected]
8
 *
9
 * This file is part of the Firefly III CSV importer
10
 * (https://github.com/firefly-iii/csv-importer).
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
24
 */
25
26
namespace App\Http\Middleware;
27
28
use Illuminate\Auth\Middleware\Authenticate as Middleware;
29
use Illuminate\Http\Request;
30
31
/**
32
 * Class Authenticate
33
 */
34
class Authenticate extends Middleware
35
{
36
    /**
37
     * Get the path the user should be redirected to when they are not authenticated.
38
     *
39
     * @param  Request  $request
40
     * @return string|null
41
     */
42
    protected function redirectTo($request)
43
    {
44
        if (! $request->expectsJson()) {
45
            return route('login');
46
        }
47
        return null;
48
    }
49
}
50