2016-01-08 16:00:57 +01:00
|
|
|
<?php
|
2017-10-21 08:40:00 +02:00
|
|
|
/**
|
|
|
|
|
* RedirectIfAuthenticated.php
|
2020-01-31 07:32:04 +01:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 08:40:00 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-02 06:37:26 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-10-21 08:40:00 +02:00
|
|
|
*/
|
2017-09-14 17:40:02 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2016-01-08 16:00:57 +01:00
|
|
|
namespace FireflyIII\Http\Middleware;
|
2015-02-06 04:39:52 +01:00
|
|
|
|
|
|
|
|
use Closure;
|
2020-03-17 15:02:57 +01:00
|
|
|
use Illuminate\Http\Request;
|
2016-01-08 16:00:57 +01:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2015-02-06 04:39:52 +01:00
|
|
|
|
2017-12-17 14:30:53 +01:00
|
|
|
/**
|
|
|
|
|
* Class RedirectIfAuthenticated
|
2018-07-22 08:10:16 +02:00
|
|
|
*
|
|
|
|
|
* @codeCoverageIgnore
|
2017-12-17 14:30:53 +01:00
|
|
|
*/
|
2015-02-11 07:35:10 +01:00
|
|
|
class RedirectIfAuthenticated
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Handle an incoming request.
|
|
|
|
|
*
|
2020-03-17 15:02:57 +01:00
|
|
|
* @param Request $request
|
|
|
|
|
* @param Closure $next
|
|
|
|
|
* @param string|null $guard
|
2017-09-14 17:40:02 +02:00
|
|
|
*
|
2015-02-11 07:35:10 +01:00
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2016-01-08 16:00:57 +01:00
|
|
|
public function handle($request, Closure $next, $guard = null)
|
2015-02-11 07:35:10 +01:00
|
|
|
{
|
2016-01-08 16:00:57 +01:00
|
|
|
if (Auth::guard($guard)->check()) {
|
2018-03-07 05:51:51 +01:00
|
|
|
return response()->redirectTo(route('index'));
|
2015-02-11 07:35:10 +01:00
|
|
|
}
|
2015-02-06 04:39:52 +01:00
|
|
|
|
2015-02-11 07:35:10 +01:00
|
|
|
return $next($request);
|
|
|
|
|
}
|
2015-02-06 04:39:52 +01:00
|
|
|
}
|