mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Refer to steam method
This commit is contained in:
parent
5d71baa4a1
commit
4e7a27dd65
@ -84,7 +84,7 @@ class DeleteController extends Controller
|
|||||||
}
|
}
|
||||||
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||||
$subTitle = (string)trans('firefly.delete_' . $objectType, ['description' => $group->title ?? $journal->description]);
|
$subTitle = (string)trans('firefly.delete_' . $objectType, ['description' => $group->title ?? $journal->description]);
|
||||||
$previous = URL::previous(route('index'));
|
$previous = app('steam')->getSafePreviousUrl(route('index'));
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
Log::debug('Will try to remember previous URI');
|
Log::debug('Will try to remember previous URI');
|
||||||
$this->rememberPreviousUri('transactions.delete.uri');
|
$this->rememberPreviousUri('transactions.delete.uri');
|
||||||
|
@ -161,6 +161,6 @@ class LinkController extends Controller
|
|||||||
{
|
{
|
||||||
$this->repository->switchLink($link);
|
$this->repository->switchLink($link);
|
||||||
|
|
||||||
return redirect(URL::previous());
|
return redirect(app('steam')->getSafePreviousUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,6 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Routing\Redirector;
|
use Illuminate\Routing\Redirector;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Illuminate\Support\ViewErrorBag;
|
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,17 +54,10 @@ trait UserNavigation
|
|||||||
final protected function getPreviousUri(string $identifier): string
|
final protected function getPreviousUri(string $identifier): string
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier));
|
Log::debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier));
|
||||||
$uri = (string)session($identifier);
|
$url = (string)session($identifier);
|
||||||
Log::debug(sprintf('The URI is %s', $uri));
|
Log::debug(sprintf('The URL is %s', $url));
|
||||||
|
|
||||||
if (str_contains($uri, 'jscript')) {
|
return app('steam')->getSafeUrl($url, route('index'));
|
||||||
$uri = $this->redirectUri;
|
|
||||||
Log::debug(sprintf('URI is now %s (uri contains jscript)', $uri));
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::debug(sprintf('Return direct link %s', $uri));
|
|
||||||
|
|
||||||
return $uri;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,27 +163,10 @@ trait UserNavigation
|
|||||||
*/
|
*/
|
||||||
final protected function rememberPreviousUri(string $identifier): ?string
|
final protected function rememberPreviousUri(string $identifier): ?string
|
||||||
{
|
{
|
||||||
$return = app('url')->previous();
|
$return = app('steam')->getSafePreviousUrl();
|
||||||
/** @var ViewErrorBag|null $errors */
|
session()->put($identifier, $return);
|
||||||
$errors = session()->get('errors');
|
|
||||||
$forbidden = ['json', 'debug'];
|
|
||||||
|
|
||||||
// get default host:
|
Log::debug(sprintf('rememberPreviousUrl: %s: "%s"', $identifier, $return));
|
||||||
$default = parse_url(route('index'), PHP_URL_HOST);
|
|
||||||
|
|
||||||
// get host of previous URL:
|
|
||||||
$previous = parse_url($return, PHP_URL_HOST);
|
|
||||||
|
|
||||||
if (null !== $previous && $default === $previous && (null === $errors || (0 === $errors->count())) && !Str::contains($return, $forbidden)) {
|
|
||||||
Log::debug(sprintf('Saving URL %s under key %s', $return, $identifier));
|
|
||||||
session()->put($identifier, $return);
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no match, save default URL:
|
|
||||||
Log::info(sprintf('Refuse to set "%s" as redirect, set default route instead.', $return));
|
|
||||||
session()->put($identifier, route('index'));
|
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user