mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-17 23:28:20 +00:00
Various code cleanup.
This commit is contained in:
@@ -130,12 +130,12 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
|
||||
if ($this->repository->currencyInUse($currency)) {
|
||||
@@ -168,12 +168,12 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info(sprintf('Tried to delete currency %s but is not site owner.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
|
||||
if ($this->repository->currencyInUse($currency)) {
|
||||
@@ -212,12 +212,12 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info(sprintf('Tried to disable currency %s but is not site owner.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
|
||||
if ($this->repository->currencyInUse($currency)) {
|
||||
@@ -268,12 +268,12 @@ class CurrencyController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info(sprintf('Tried to edit currency %s but is not owner.', $currency->code));
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
|
||||
$subTitleIcon = 'fa-pencil';
|
||||
@@ -355,12 +355,12 @@ class CurrencyController extends Controller
|
||||
$user = auth()->user();
|
||||
$data = $request->getCurrencyData();
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
Log::error('User ' . auth()->user()->id . ' is not admin, but tried to store a currency.');
|
||||
Log::channel('audit')->info('Tried to create (POST) currency without admin rights.', $data);
|
||||
|
||||
return redirect($this->getPreviousUri('currencies.create.uri'));
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
|
||||
$data['enabled'] = true;
|
||||
@@ -378,11 +378,11 @@ class CurrencyController extends Controller
|
||||
$request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));
|
||||
Log::channel('audit')->info('Created (POST) currency.', $data);
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$request->session()->put('currencies.create.fromStore', true);
|
||||
|
||||
$redirect = redirect(route('currencies.create'))->withInput();
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,12 +406,12 @@ class CurrencyController extends Controller
|
||||
$data['enabled'] = true;
|
||||
}
|
||||
if (!$this->userRepository->hasRole($user, 'owner')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));
|
||||
Log::channel('audit')->info('Tried to update (POST) currency without admin rights.', $data);
|
||||
|
||||
return redirect(route('currencies.index'));
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
$currency = $this->repository->update($currency, $data);
|
||||
Log::channel('audit')->info('Updated (POST) currency.', $data);
|
||||
@@ -419,11 +419,11 @@ class CurrencyController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
$request->session()->put('currencies.edit.fromUpdate', true);
|
||||
|
||||
return redirect(route('currencies.edit', [$currency->id]));
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
}
|
||||
|
||||
return redirect($this->getPreviousUri('currencies.edit.uri'));
|
||||
|
||||
Reference in New Issue
Block a user