Skip to content

Commit

Permalink
Minor change to MachineGroupMembership.php which uses BU config enabl…
Browse files Browse the repository at this point in the history
…ed/disabled instead of session var to determine whether to check for machine group business units
  • Loading branch information
mosen committed Jan 2, 2024
1 parent ad76d32 commit 5a91942
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions app/Auth/Listeners/MachineGroupMembership.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,9 @@
class MachineGroupMembership
{
public function handle(Login $event) {
Log::info('evaluating machinegroup memberships');
if( session()->has('business_unit')){
// Only retrieve machinegroups for this business unit
$businessUnitId = session()->get('business_unit');
$machineGroups = BusinessUnit::where('unitid', $businessUnitId)
->where('property', 'machine_group')
->get()
->pluck('value')
->toArray();
}
else{
Log::debug('evaluating machinegroup memberships');

if (!config('_munkireport.enable_business_units', false) || $event->user->role === 'admin') {
// Can access all defined groups (from machine_group)
// and used groups (from reportdata)
$mg = new Machine_group;
Expand All @@ -39,8 +31,17 @@ public function handle(Login $event) {
->toArray();
$reportedMachineGroups = $reportedMachineGroups ? $reportedMachineGroups : [0];
$machineGroups = array_unique(array_merge($reportedMachineGroups, $mg->get_group_ids()));
} else {
// Only retrieve machinegroups for this business unit
$businessUnitId = session()->get('business_unit');
$machineGroups = BusinessUnit::where('unitid', $businessUnitId)
->where('property', 'machine_group')
->get()
->pluck('value')
->toArray();
}
Log::info('found machinegroup memberships: ', $machineGroups);

Log::debug('found machinegroup memberships: ', $machineGroups);
session()->put('machine_groups', $machineGroups);
}
}

0 comments on commit 5a91942

Please sign in to comment.