enh: groupInfo: nicer message when no egress key exists

This commit is contained in:
Stéphane Lesimple 2021-02-15 11:15:21 +00:00 committed by Stéphane Lesimple
parent 3b37242317
commit 7eeccb7c5d
2 changed files with 6 additions and 3 deletions

View file

@ -59,7 +59,7 @@ if (!$mfaRequired && !defined $ttl) {
#<HEADER
#>PARAMS:ACCOUNT
#>PARAMS:GROUP
$fnret = OVH::Bastion::is_valid_group_and_existing(group => $group, groupType => "key");
$fnret or HEXIT($fnret);
@ -67,7 +67,7 @@ $fnret or HEXIT($fnret);
$group = $fnret->value->{'group'};
my $shortGroup = $fnret->value->{'shortGroup'};
#<PARAMS:ACCOUNT
#<PARAMS:GROUP
#>RIGHTSCHECK
if ($self eq 'root') {

View file

@ -185,7 +185,10 @@ if ($fnret) {
$fnret = OVH::Bastion::get_group_keys(group => $group);
if ($fnret and $from) {
osh_info ' ';
if (@{$fnret->value->{'sortedKeys'}} == 1) {
if ($fnret->value && !@{$fnret->value->{'sortedKeys'}}) {
osh_info "This group has no SSH egress key, the owner may use groupGenerateEgressKey to generate one.";
}
elsif (@{$fnret->value->{'sortedKeys'}} == 1) {
osh_info "The public key of this group is:";
}
else {