From 647f47cdfed4fb6fb65bb017b64df72c23f9e878 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 21 Mar 2023 19:27:05 -0700 Subject: [PATCH] Check for demo mode in the clear method for the controller Signed-off-by: snipe --- app/Helpers/Helper.php | 4 ++-- app/Http/Livewire/SlackSettingsForm.php | 22 +++++++++++-------- .../livewire/slack-settings-form.blade.php | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 276aa4db33..541d4070ff 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -1155,10 +1155,10 @@ class Helper * This makes it cleanly available in blades and in controllers, e.g. * * Blade: - * {{ app('demo_mode') ? ' disabled' : ''}} for form blades where we need to disable a form + * {{ Helper::isDemoMode() ? ' disabled' : ''}} for form blades where we need to disable a form * * Controller: - * if (app('demo_mode')) { + * if (Helper::isDemoMode()) { * // don't allow the thing * } * @todo - use this everywhere else in the app where we have very long if/else config('app.lock_passwords') stuff diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index 97750cd198..4f8b33ac05 100644 --- a/app/Http/Livewire/SlackSettingsForm.php +++ b/app/Http/Livewire/SlackSettingsForm.php @@ -131,21 +131,25 @@ class SlackSettingsForm extends Component } public function clearSettings(){ - $this->webhook_endpoint = ''; - $this->webhook_channel = ''; - $this->webhook_botname = ''; - $this->setting->webhook_endpoint = ''; - $this->setting->webhook_channel = ''; - $this->setting->webhook_botname = ''; + if (Helper::isDemoMode()) { + session()->flash('error',trans('general.feature_disabled')); + } else { + $this->webhook_endpoint = ''; + $this->webhook_channel = ''; + $this->webhook_botname = ''; + $this->setting->webhook_endpoint = ''; + $this->setting->webhook_channel = ''; + $this->setting->webhook_botname = ''; - $this->setting->save(); + $this->setting->save(); - session()->flash('success',trans('admin/settings/message.update.success')); + session()->flash('success', trans('admin/settings/message.update.success')); + } } public function submit() { - if (app('demo_mode')) { + if (Helper::isDemoMode()) { session()->flash('error',trans('general.feature_disabled')); } else { if ($this->webhook_selected != 'general') { diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php index 5634dfa1dd..08ef670b12 100644 --- a/resources/views/livewire/slack-settings-form.blade.php +++ b/resources/views/livewire/slack-settings-form.blade.php @@ -141,7 +141,7 @@