2017-10-27 18:56:38 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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;
|
2019-03-08 17:57:42 +01:00
|
|
|
use Log;
|
2017-10-27 18:56:38 +02:00
|
|
|
|
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Class StartFireflySession.
|
2018-07-22 08:10:16 +02:00
|
|
|
*
|
|
|
|
* @codeCoverageIgnore
|
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.
|
|
|
|
*
|
2020-03-17 15:02:57 +01: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
|
|
|
{
|
2019-03-24 14:48:12 +01:00
|
|
|
$uri = $request->fullUrl();
|
2019-03-17 07:31:12 +01:00
|
|
|
$isScriptPage = strpos($uri, 'jscript');
|
2019-03-24 14:48:12 +01:00
|
|
|
$isDeletePage = strpos($uri, 'delete');
|
|
|
|
$isLoginPage = strpos($uri, '/login');
|
2020-03-17 15:02:57 +01:00
|
|
|
$isJsonPage = strpos($uri, '/json');
|
2019-03-08 17:57:42 +01:00
|
|
|
|
2019-03-17 07:31:12 +01:00
|
|
|
// also stop remembering "delete" URL's.
|
|
|
|
|
2019-03-24 14:48:12 +01:00
|
|
|
if (false === $isScriptPage && false === $isDeletePage
|
2020-03-17 15:02:57 +01:00
|
|
|
&& false === $isLoginPage
|
|
|
|
&& false === $isJsonPage
|
2019-03-24 14:48:12 +01:00
|
|
|
&& 'GET' === $request->method()
|
|
|
|
&& !$request->ajax()) {
|
2017-10-29 20:02:34 +01:00
|
|
|
$session->setPreviousUrl($uri);
|
2020-03-15 15:31:51 +01:00
|
|
|
Log::debug(sprintf('Will set previous URL to %s', $uri));
|
2019-03-08 17:57:42 +01:00
|
|
|
|
|
|
|
return;
|
2017-10-29 20:02:34 +01:00
|
|
|
}
|
2020-03-15 15:31:51 +01:00
|
|
|
Log::debug(sprintf('Will NOT set previous URL to %s', $uri));
|
2017-10-29 20:02:34 +01:00
|
|
|
}
|
2017-11-08 09:05:10 +01:00
|
|
|
}
|