From 914a760e25a5e991323f60915de70084821bb5a9 Mon Sep 17 00:00:00 2001 From: Maxime Besson Date: Tue, 1 Oct 2019 14:10:22 +0200 Subject: [PATCH] Fix Choice parameter overload in manager (#1962) --- .../lib/Lemonldap/NG/Common/Conf/RESTServer.pm | 13 +++++++++---- .../lib/Lemonldap/NG/Manager/Conf/Parser.pm | 6 ++++-- .../site/htdocs/static/forms/authChoice.html | 5 +++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm index d6624437c..bc12b02ee 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm @@ -541,10 +541,15 @@ sub authChoiceModules { my @res; foreach my $k ( sort keys %$value ) { my $data = [ split /;/, $value->{$k} ]; - eval { $data->[5] = from_json( $data->[5] ) if $data->[5] }; - if ($@) { - $self->logger->error( - "Bad value in choice over parameters, deleted ($@)"); + if ( $data->[5] ) { + my $over; + eval { $over = from_json( $data->[5] ) }; + if ($@) { + $self->logger->error( + "Bad value in choice over parameters, deleted ($@)"); + } else { + $data->[5] = [ map { [ $_, $over->{$_} ] } keys %{$over} ]; + } } push @res, { diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm index f42d4e88a..ef5a765e5 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm @@ -846,9 +846,11 @@ sub _scanNodes { # authChoiceModules if ( $name eq 'authChoiceModules' ) { - hdebug(' combModules'); + hdebug(' authChoiceModules'); $n->{data}->[5] ||= {}; - $n->{data}->[5] = to_json( $n->{data}->[5] ); + $n->{data}->[5] = + to_json( { map { @$_ } @{ $n->{data}->[5] } } ) + if ref( $n->{data}->[5] ) eq 'ARRAY'; } $n->{data} = join ';', @{ $n->{data} }; diff --git a/lemonldap-ng-manager/site/htdocs/static/forms/authChoice.html b/lemonldap-ng-manager/site/htdocs/static/forms/authChoice.html index 60b229b9f..24ed99b79 100644 --- a/lemonldap-ng-manager/site/htdocs/static/forms/authChoice.html +++ b/lemonldap-ng-manager/site/htdocs/static/forms/authChoice.html @@ -42,8 +42,9 @@ - - + +