1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* RedirectIfAuthenticated.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 App\Providers\RouteServiceProvider; |
29
|
|
|
use Closure; |
30
|
|
|
use Illuminate\Http\Request; |
31
|
|
|
use Illuminate\Support\Facades\Auth; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Class RedirectIfAuthenticated |
35
|
|
|
*/ |
36
|
|
|
class RedirectIfAuthenticated |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* Handle an incoming request. |
40
|
|
|
* |
41
|
|
|
* @param Request $request |
42
|
|
|
* @param Closure $next |
43
|
|
|
* @param string|null $guard |
44
|
|
|
* @return mixed |
45
|
|
|
*/ |
46
|
|
|
public function handle($request, Closure $next, $guard = null) |
47
|
|
|
{ |
48
|
|
|
if (Auth::guard($guard)->check()) { |
49
|
|
|
return redirect(RouteServiceProvider::HOME); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return $next($request); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|