Merge pull request #14441 from Godmartinz/ldap_location-resync
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run

Fixes Assets location not being resynced when Users location is updated via LDAP
This commit is contained in:
snipe 2024-11-12 22:35:11 +00:00 committed by GitHub
commit 787340b987
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Models\Asset;
use App\Models\Department; use App\Models\Department;
use App\Models\Group; use App\Models\Group;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@ -418,6 +419,8 @@ class LdapSync extends Command
if ($item['createorupdate'] === 'created' && $ldap_default_group) { if ($item['createorupdate'] === 'created' && $ldap_default_group) {
$user->groups()->attach($ldap_default_group); $user->groups()->attach($ldap_default_group);
} }
//updates assets location based on user's location
Asset::where('assigned_to', '=', $user->id)->update(['location_id' => $user->location_id]);
} else { } else {
foreach ($user->getErrors()->getMessages() as $key => $err) { foreach ($user->getErrors()->getMessages() as $key => $err) {