1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #7720 from turbo124/v5-stable

Fixes for company token generation
This commit is contained in:
David Bomba 2022-08-06 07:51:39 +10:00 committed by GitHub
commit a16744311d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
/public/storage /public/storage
/public/react /public/react
/storage/*.key /storage/*.key
/storage/debugbar
/vendor /vendor
/.idea /.idea
/.vscode /.vscode

View File

@ -15,6 +15,7 @@ use App\DataMapper\CompanySettings;
use App\Events\User\UserWasArchived; use App\Events\User\UserWasArchived;
use App\Events\User\UserWasDeleted; use App\Events\User\UserWasDeleted;
use App\Events\User\UserWasRestored; use App\Events\User\UserWasRestored;
use App\Jobs\Company\CreateCompanyToken;
use App\Models\CompanyUser; use App\Models\CompanyUser;
use App\Models\User; use App\Models\User;
use App\Utils\Ninja; use App\Utils\Ninja;
@ -56,10 +57,11 @@ class UserRepository extends BaseRepository
$account = $company->account; $account = $company->account;
/* If hosted and Enterprise we need to increment the num_users field on the accounts table*/ /* If hosted and Enterprise we need to increment the num_users field on the accounts table*/
if (! $user->id && $account->isEnterpriseClient()) { // 05-08-2022 This is an error, the num_users should _never_ increment
$account->num_users++; // if (! $user->id && $account->isEnterpriseClient()) {
$account->save(); // $account->num_users++;
} // $account->save();
// }
$user->fill($details); $user->fill($details);
@ -94,6 +96,12 @@ class UserRepository extends BaseRepository
$cu->restore(); $cu->restore();
$cu->tokens()->restore(); $cu->tokens()->restore();
$cu->save(); $cu->save();
//05-08-2022
if($cu->tokens()->count() == 0){
(new CreateCompanyToken($cu->company, $cu->user, 'restored_user'))->handle();
}
} else { } else {
$cu->notifications = $data['company_user']['notifications']; $cu->notifications = $data['company_user']['notifications'];
$cu->settings = $data['company_user']['settings']; $cu->settings = $data['company_user']['settings'];