improved tenant identification
This commit is contained in:
@@ -15,21 +15,6 @@ class Login
|
||||
*/
|
||||
public function handle(Event $event)
|
||||
{
|
||||
// Get first company
|
||||
$company = $event->user->companies()->enabled()->first();
|
||||
|
||||
// Logout if no company assigned
|
||||
if (!$company) {
|
||||
app('App\Http\Controllers\Auth\Login')->logout();
|
||||
|
||||
flash(trans('auth.error.no_company'))->error()->important();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Set company id
|
||||
session(['company_id' => $company->id]);
|
||||
|
||||
// Save user login time
|
||||
$event->user->last_logged_in_at = Date::now();
|
||||
|
||||
|
||||
@@ -29,17 +29,17 @@ class AddAdminItems
|
||||
if (session('dashboard_id') != $dashboard->id) {
|
||||
$sub->route('dashboards.switch', $dashboard->name, ['dashboard' => $dashboard->id], $key, $attr);
|
||||
} else {
|
||||
$sub->url('/', $dashboard->name, $key, $attr);
|
||||
$sub->url('/' . company_id(), $dashboard->name, $key, $attr);
|
||||
}
|
||||
}
|
||||
}, 10, [
|
||||
'url' => '/',
|
||||
'url' => '/' . company_id(),
|
||||
'title' => trans_choice('general.dashboards', 2),
|
||||
'icon' => 'fa fa-tachometer-alt',
|
||||
]);
|
||||
} else {
|
||||
$menu->add([
|
||||
'url' => '/',
|
||||
'url' => '/' . company_id(),
|
||||
'title' => trans_choice('general.dashboards', 1),
|
||||
'icon' => 'fa fa-tachometer-alt',
|
||||
'order' => 10,
|
||||
|
||||
@@ -51,7 +51,7 @@ class UpdateExtraModules
|
||||
continue;
|
||||
}
|
||||
|
||||
$company_id = session('company_id');
|
||||
$company_id = company_id();
|
||||
|
||||
$command = "update {$alias} {$company_id} {$latest_version}";
|
||||
|
||||
|
||||
@@ -70,34 +70,25 @@ class Version200 extends Listener
|
||||
|
||||
protected function updateCompanies()
|
||||
{
|
||||
$company_id = session('company_id');
|
||||
$company_id = company_id();
|
||||
|
||||
$companies = Company::cursor();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
session(['company_id' => $company->id]);
|
||||
$company->makeCurrent();
|
||||
|
||||
$this->updateSettings($company);
|
||||
$this->updateSettings();
|
||||
|
||||
$this->createEmailTemplates($company);
|
||||
|
||||
$this->createReports($company);
|
||||
}
|
||||
|
||||
setting()->forgetAll();
|
||||
|
||||
session(['company_id' => $company_id]);
|
||||
|
||||
Overrider::load('settings');
|
||||
company($company_id)->makeCurrent();
|
||||
}
|
||||
|
||||
public function updateSettings($company)
|
||||
public function updateSettings()
|
||||
{
|
||||
// Set the active company settings
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
setting()->forgetAll();
|
||||
setting()->load(true);
|
||||
|
||||
// Override settings
|
||||
config(['app.url' => route('dashboard')]);
|
||||
config(['app.timezone' => setting('general.timezone', 'UTC')]);
|
||||
|
||||
@@ -30,30 +30,21 @@ class Version203 extends Listener
|
||||
|
||||
protected function updateCompanies()
|
||||
{
|
||||
$company_id = session('company_id');
|
||||
$company_id = company_id();
|
||||
|
||||
$companies = Company::cursor();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
session(['company_id' => $company->id]);
|
||||
$company->makeCurrent();
|
||||
|
||||
$this->updateSettings($company);
|
||||
}
|
||||
|
||||
setting()->forgetAll();
|
||||
|
||||
session(['company_id' => $company_id]);
|
||||
|
||||
Overrider::load('settings');
|
||||
company($company_id)->makeCurrent();
|
||||
}
|
||||
|
||||
public function updateSettings($company)
|
||||
{
|
||||
// Set the active company settings
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
setting()->forgetAll();
|
||||
setting()->load(true);
|
||||
|
||||
setting()->set(['invoice.payment_terms' => setting('invoice.payment_terms', 0)]);
|
||||
|
||||
setting()->save();
|
||||
|
||||
@@ -1031,24 +1031,20 @@ class Version210 extends Listener
|
||||
|
||||
protected function updateCompanies()
|
||||
{
|
||||
$company_id = session('company_id');
|
||||
$company_id = company_id();
|
||||
|
||||
$companies = Company::cursor();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
session(['company_id' => $company->id]);
|
||||
$company->makeCurrent();
|
||||
|
||||
$this->updateSettings($company);
|
||||
$this->updateSettings();
|
||||
}
|
||||
|
||||
setting()->forgetAll();
|
||||
|
||||
session(['company_id' => $company_id]);
|
||||
|
||||
Overrider::load('settings');
|
||||
company($company_id)->makeCurrent();
|
||||
}
|
||||
|
||||
public function updateSettings($company)
|
||||
public function updateSettings()
|
||||
{
|
||||
$income_category = Category::income()->enabled()->first();
|
||||
$expense_category = Category::expense()->enabled()->first();
|
||||
@@ -1057,11 +1053,6 @@ class Version210 extends Listener
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the active company settings
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
setting()->forgetAll();
|
||||
setting()->load(true);
|
||||
|
||||
setting()->set(['default.income_category' => setting('default.income_category', $income_category->id)]);
|
||||
setting()->set(['default.expense_category' => setting('default.expense_category', $expense_category->id)]);
|
||||
|
||||
|
||||
@@ -30,30 +30,21 @@ class Version213 extends Listener
|
||||
|
||||
protected function updateCompanies()
|
||||
{
|
||||
$company_id = session('company_id');
|
||||
$company_id = company_id();
|
||||
|
||||
$companies = Company::cursor();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
session(['company_id' => $company->id]);
|
||||
$company->makeCurrent();
|
||||
|
||||
$this->updateSettings($company);
|
||||
$this->updateSettings();
|
||||
}
|
||||
|
||||
setting()->forgetAll();
|
||||
|
||||
session(['company_id' => $company_id]);
|
||||
|
||||
Overrider::load('settings');
|
||||
company($company_id)->makeCurrent();
|
||||
}
|
||||
|
||||
public function updateSettings($company)
|
||||
public function updateSettings()
|
||||
{
|
||||
// Set the active company settings
|
||||
setting()->setExtraColumns(['company_id' => $company->id]);
|
||||
setting()->forgetAll();
|
||||
setting()->load(true);
|
||||
|
||||
$company_logo = setting('company.logo');
|
||||
|
||||
if (is_array($company_logo)) {
|
||||
|
||||
Reference in New Issue
Block a user