2017-10-27 18:56:38 +02:00
|
|
|
<?php
|
2022-12-29 19:42:26 +01:00
|
|
|
|
2017-10-27 18:56:38 +02:00
|
|
|
/**
|
|
|
|
* StartFireflySession.php
|
2020-01-31 07:32:04 +01:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2017-10-27 18:56:38 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2017-10-27 18:56:38 +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-27 18:56:38 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-27 18:56:38 +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-27 18:56:38 +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-27 18:56:38 +02:00
|
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace FireflyIII\Http\Middleware;
|
|
|
|
|
2020-03-17 15:02:57 +01:00
|
|
|
use Illuminate\Contracts\Session\Session;
|
2017-10-27 18:56:38 +02:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Session\Middleware\StartSession;
|
|
|
|
|
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Class StartFireflySession.
|
2018-07-22 08:10:16 +02:00
|
|
|
*
|
2023-02-12 07:15:06 +01:00
|
|
|
|
2017-10-27 18:56:38 +02:00
|
|
|
*/
|
|
|
|
class StartFireflySession extends StartSession
|
|
|
|
{
|
2017-10-29 20:02:34 +01:00
|
|
|
/**
|
|
|
|
* Store the current URL for the request if necessary.
|
|
|
|
*
|
2023-06-21 12:34:58 +02:00
|
|
|
* @param Request $request
|
|
|
|
* @param Session $session
|
2017-10-29 20:02:34 +01:00
|
|
|
*/
|
2018-07-08 12:28:42 +02:00
|
|
|
protected function storeCurrentUrl(Request $request, $session): void
|
2017-10-29 20:02:34 +01:00
|
|
|
{
|
2021-10-03 06:06:49 +02:00
|
|
|
$url = $request->fullUrl();
|
|
|
|
$safeUrl = app('steam')->getSafeUrl($url, route('index'));
|
2019-03-08 17:57:42 +01:00
|
|
|
|
2021-10-03 06:06:49 +02:00
|
|
|
if ($url !== $safeUrl) {
|
2021-10-01 05:30:05 +02:00
|
|
|
return;
|
2017-10-29 20:02:34 +01:00
|
|
|
}
|
2021-10-03 06:06:49 +02:00
|
|
|
|
|
|
|
if ('GET' === $request->method() && !$request->ajax()) {
|
|
|
|
$session->setPreviousUrl($safeUrl);
|
|
|
|
}
|
2017-10-29 20:02:34 +01:00
|
|
|
}
|
2017-11-08 09:05:10 +01:00
|
|
|
}
|