prevent disable active company

This commit is contained in:
denisdulici 2020-02-13 16:09:24 +03:00
parent 0db2bffd03
commit 197f9f9e3a
2 changed files with 8 additions and 0 deletions

View File

@ -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');

View File

@ -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!',
],
];