From 197f9f9e3a7c11eb7c58961a9f2e1f8da0c6ffe8 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Thu, 13 Feb 2020 16:09:24 +0300 Subject: [PATCH] prevent disable active company --- app/Jobs/Common/UpdateCompany.php | 7 +++++++ resources/lang/en-GB/companies.php | 1 + 2 files changed, 8 insertions(+) diff --git a/app/Jobs/Common/UpdateCompany.php b/app/Jobs/Common/UpdateCompany.php index b5fbe610b..e376a4c47 100644 --- a/app/Jobs/Common/UpdateCompany.php +++ b/app/Jobs/Common/UpdateCompany.php @@ -89,6 +89,13 @@ class UpdateCompany extends Job */ public function authorize() { + // Can't disable active company + if (($this->request->get('enabled', 1) == 0) && ($this->company->id == session('company_id'))) { + $message = trans('companies.error.disable_active'); + + throw new \Exception($message); + } + // Check if user can access company if (!$this->isUserCompany($this->company->id)) { $message = trans('companies.error.not_user_company'); diff --git a/resources/lang/en-GB/companies.php b/resources/lang/en-GB/companies.php index 8415b2f8b..44e97402c 100644 --- a/resources/lang/en-GB/companies.php +++ b/resources/lang/en-GB/companies.php @@ -8,6 +8,7 @@ return [ 'error' => [ 'not_user_company' => 'Error: You are not allowed to change this company!', 'delete_active' => 'Error: Can not delete the active company. Please, switch to another first!', + 'disable_active' => 'Error: Can not disable the active company. Please, switch to another first!', ], ];