Change priority on audit messages.

This commit is contained in:
James Cole
2024-01-09 20:48:17 +01:00
parent 0dfa21a92e
commit 6fbf9a119d
39 changed files with 79 additions and 47 deletions

View File

@@ -105,7 +105,7 @@ class CreateController extends Controller
$data = $request->getCurrencyData();
if (!$this->userRepository->hasRole($user, 'owner')) {
app('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);
Log::channel('audit')->warning('Tried to create (POST) currency without admin rights.', $data);
return redirect($this->getPreviousUrl('currencies.create.url'))->withInput();
}
@@ -116,7 +116,7 @@ class CreateController extends Controller
$currency = $this->repository->store($data);
} catch (FireflyException $e) {
app('log')->error($e->getMessage());
Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data);
Log::channel('audit')->warning('Could not store (POST) currency without admin rights.', $data);
$request->session()->flash('error', (string)trans('firefly.could_not_store_currency'));
$currency = null;
}

View File

@@ -74,7 +74,7 @@ class DeleteController extends Controller
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$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));
Log::channel('audit')->warning(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code));
return redirect(route('currencies.index'));
}
@@ -83,7 +83,7 @@ class DeleteController extends Controller
$location = $this->repository->currencyInUseAt($currency);
$message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);
$request->session()->flash('error', $message);
Log::channel('audit')->info(sprintf('Tried to visit page to delete currency %s but currency is in use.', $currency->code));
Log::channel('audit')->warning(sprintf('Tried to visit page to delete currency %s but currency is in use.', $currency->code));
return redirect(route('currencies.index'));
}
@@ -107,7 +107,7 @@ class DeleteController extends Controller
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$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));
Log::channel('audit')->warning(sprintf('Tried to delete currency %s but is not site owner.', $currency->code));
return redirect(route('currencies.index'));
}

View File

@@ -72,7 +72,7 @@ class EditController extends Controller
$user = auth()->user();
if (!$this->userRepository->hasRole($user, 'owner')) {
$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));
Log::channel('audit')->warning(sprintf('Tried to edit currency %s but is not owner.', $currency->code));
return redirect(route('currencies.index'));
}
@@ -120,7 +120,7 @@ class EditController extends Controller
if (!$this->userRepository->hasRole($user, 'owner')) {
$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);
Log::channel('audit')->warning('Tried to update (POST) currency without admin rights.', $data);
return redirect(route('currencies.index'));
}