Skip to content

Commit

Permalink
Only show registered nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouzierinverse committed Feb 26, 2025
1 parent 69e6863 commit afc2707
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ sub is_lost_stolen {
sub userIsAuthenticated : Private {
my ( $self, $c ) = @_;
my $pid = $c->user_session->{"username"} // $c->{_session}->{username};
my @person_nodes = person_nodes($pid);
my @person_nodes = person_reg_nodes($pid);
my @nodes;
foreach my $person_node (@person_nodes) {
my $node = node_view($person_node->{mac});
Expand Down
22 changes: 22 additions & 0 deletions lib/pf/person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ BEGIN {
person_view_simple
person_modify
person_nodes
person_reg_nodes
person_security_events
person_cleanup
persons_without_nodes
Expand Down Expand Up @@ -282,6 +283,27 @@ sub person_nodes {
return @{$iter->all // []};
}

sub person_reg_nodes {
my ($pid) = @_;
my ($status, $iter) = pf::dal::node->search(
-where => {
pid => $pid,
},
-columns => [qw(mac pid notes regdate unregdate status user_agent computername device_class time_balance bandwidth_balance)],
#To avoid join
-from => pf::dal::node->table,
-with_class => undef,
-where => {
status => "reg",
},
);
if (is_error($status)) {
return;
}

return @{$iter->all // []};
}

=head2 person_unassign_nodes
unassign the nodes of a person
Expand Down

0 comments on commit afc2707

Please sign in to comment.