Hide portctl features in Device Ports where ACLs would not permit the action

This commit is contained in:
Oliver Gorwits
2021-09-03 08:07:01 +01:00
parent b368ae9b11
commit 691cedb3c6
3 changed files with 19 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ use Dancer ':syntax';
use Dancer::Plugin::DBIC;
use Dancer::Plugin::Auth::Extensible;
use App::Netdisco::Util::Port 'port_reconfig_check';
use App::Netdisco::Util::Web (); # for sort_port
use App::Netdisco::Web::Plugin;
@@ -202,6 +203,11 @@ get '/ajax/content/device/ports' => require_login sub {
# sort ports
@results = sort { &App::Netdisco::Util::Web::sort_port($a->port, $b->port) } @results;
# add acl on port config
if (param('c_admin') and user_has_role('port_control')) {
map {$_->{portctl} = (port_reconfig_check($_) ? false : true)} @results;
}
# empty set would be a 'no records' msg
return unless scalar @results;