1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02: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/react
/storage/*.key
/storage/debugbar
/vendor
/.idea
/.vscode

View File

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