A free open source IT asset/license management system
Skip user records if user exists in another company if FMCS is enabled
snipe988729fbebdd
diff --git a/app/Importer/UserImporter.php b/app/Importer/UserImporter.phpindex 7be5ef60cc..cf33267c70 100644--- a/app/Importer/UserImporter.php+++ b/app/Importer/UserImporter.php@@ -165,6 +165,17 @@ class UserImporter extends ItemImporterreturn;}+ // With FMCS enabled, the scoped lookup above only sees users in the current user's companies.+ // If the username exists in another company it would appear as "not found" and fall through+ // to create — but usernames are unique system-wide, so we must skip instead.+ if (Auth::check() && Company::isFullMultipleCompanySupportEnabled()) {+ if (User::withoutGlobalScopes()->where('username', $this->item['username'])->exists()) {+ $this->log('Skipping '.$this->item['username'].': username belongs to a user outside your company scope.');++ return;+ }+ }+// This needs to be applied after the update logic, otherwise we'll overwrite user passwords// Issue #5408$this->item['password'] = $this->tempPassword;