Files
firefly-iii/app/Http/Middleware/StartFireflySession.php

58 lines
1.9 KiB
PHP
Raw Normal View History

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
*
* This file is part of Firefly III (https://github.com/firefly-iii).
2017-10-27 18:56:38 +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
*
* 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
* GNU Affero General Public License for more details.
2017-10-27 18:56:38 +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;
use Illuminate\Contracts\Session\Session;
2017-10-27 18:56:38 +02:00
use Illuminate\Http\Request;
use Illuminate\Session\Middleware\StartSession;
2021-10-01 05:30:05 +02: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.
*
* @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-01 05:30:05 +02:00
$url = $request->fullUrl();
$forbiddenWords = strpos($url, 'offline') || strpos($url, 'jscript') || strpos($url, 'delete') || strpos($url, '/login') || strpos($url, '/json') || strpos($url, 'serviceworker') || strpos($url, '/attachments/view');
2021-10-01 05:30:05 +02:00
if (false === $forbiddenWords
&& 'GET' === $request->method()
&& !$request->ajax()) {
2021-10-02 12:50:06 +02:00
//Log::debug(sprintf('Redirect is now "%s".', $url));
2021-10-01 05:30:05 +02:00
$session->setPreviousUrl($url);
return;
2017-10-29 20:02:34 +01:00
}
2021-10-02 12:50:06 +02:00
//Log::debug(sprintf('Refuse to set "%s" as current URL.', $url));
2017-10-29 20:02:34 +01:00
}
2017-11-08 09:05:10 +01:00
}