Revert "Translate incoming JSON bools (#2318)"

This reverts commit 85574cf97e.
This commit is contained in:
Maxime Besson 2020-12-28 15:18:47 +01:00
parent aac77c2498
commit b1545bce5b
6 changed files with 26 additions and 47 deletions

View File

@ -159,25 +159,4 @@ sub _getSSOMod {
return $mod;
}
sub _fix_bool {
my $h = shift;
if ( ref($h) eq "HASH" ) {
for my $k ( keys %{$h} ) {
if ( JSON::is_bool( $h->{$k} ) ) {
$h->{$k} = $h->{$k} ? 1 : 0;
}
else {
_fix_bool( $h->{$k} );
}
}
}
}
sub getJsonBody {
my ( $self, $req ) = @_;
my $obj = $req->jsonBodyToObj;
_fix_bool($obj);
return $obj;
}
1;

View File

@ -58,7 +58,7 @@ sub getMenuApp {
my @menuApps =
map {
$self->_isCatApp( $cat->{$_} )
$self->_isCatApp( $cat->{$_} )
? $self->_getMenuAppByConfKey( $conf, $catConfKey, $_ )
: ()
}
@ -105,7 +105,7 @@ sub findMenuAppByConfKey {
my @menuApps =
map {
$self->_isCatApp( $cat->{$_} )
$self->_isCatApp( $cat->{$_} )
&& $_ =~ $pattern
? $self->_getMenuAppByConfKey( $conf, $catConfKey, $_ )
: ()
@ -117,7 +117,7 @@ sub findMenuAppByConfKey {
sub addMenuApp {
my ( $self, $req ) = @_;
my $add = $self->getJsonBody($req);
my $add = $req->jsonBodyToObj;
my $catConfKey = $req->params('confKey')
or return $self->sendError( $req, 'Category confKey is missing', 400 );
@ -132,8 +132,8 @@ sub addMenuApp {
400 )
if ( ref $add->{confKey} );
return $self->sendError( $req,
'Invalid input: confKey contains invalid characters', 400 )
return $self->sendError( $req, 'Invalid input: confKey contains invalid characters',
400 )
unless ( $add->{confKey} =~ '^\w[\w\.\-]*$' );
return $self->sendError( $req, 'Invalid input: name is missing', 400 )
@ -185,7 +185,7 @@ sub updateMenuApp {
my $appConfKey = $req->params('appConfKey')
or return $self->sendError( $req, 'Application confKey is missing', 400 );
my $update = $self->getJsonBody($req);
my $update = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($update);
@ -229,7 +229,7 @@ sub replaceMenuApp {
my $appConfKey = $req->params('appConfKey')
or return $self->sendError( $req, 'Application confKey is missing', 400 );
my $replace = $self->getJsonBody($req);
my $replace = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($replace);
@ -241,10 +241,10 @@ sub replaceMenuApp {
400 )
if ( ref $replace->{confKey} );
return $self->sendError( $req,
'Invalid input: confKey contains invalid characters', 400 )
return $self->sendError( $req, 'Invalid input: confKey contains invalid characters',
400 )
unless ( $replace->{confKey} =~ '^\w[\w\.\-]*$' );
return $self->sendError( $req, 'Invalid input: name is missing', 400 )
unless ( defined $replace->{options}
&& defined $replace->{options}{name} );

View File

@ -64,7 +64,7 @@ sub findMenuCatByConfKey {
sub addMenuCat {
my ( $self, $req ) = @_;
my $add = $self->getJsonBody($req);
my $add = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($add);
@ -76,8 +76,8 @@ sub addMenuCat {
400 )
if ( ref $add->{confKey} );
return $self->sendError( $req,
'Invalid input: confKey contains invalid characters', 400 )
return $self->sendError( $req, 'Invalid input: confKey contains invalid characters',
400 )
unless ( $add->{confKey} =~ '^\w[\w\.\-]*$' );
return $self->sendError( $req, 'Invalid input: catname is missing', 400 )
@ -116,7 +116,7 @@ sub updateMenuCat {
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
my $update = $self->getJsonBody($req);
my $update = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($update);
@ -147,7 +147,7 @@ sub replaceMenuCat {
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
my $replace = $self->getJsonBody($req);
my $replace = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($replace);
@ -159,8 +159,8 @@ sub replaceMenuCat {
400 )
if ( ref $replace->{confKey} );
return $self->sendError( $req,
'Invalid input: confKey contains invalid characters', 400 )
return $self->sendError( $req, 'Invalid input: confKey contains invalid characters',
400 )
unless ( $replace->{confKey} =~ '^\w[\w\.\-]*$' );
return $self->sendError( $req, 'Invalid input: catname is missing', 400 )

View File

@ -91,7 +91,7 @@ sub findCasAppsByServiceUrl {
sub addCasApp {
my ( $self, $req ) = @_;
my $add = $self->getJsonBody($req);
my $add = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($add);
@ -153,7 +153,7 @@ sub updateCasApp {
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
my $update = $self->getJsonBody($req);
my $update = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($update);
@ -190,7 +190,7 @@ sub replaceCasApp {
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
my $replace = $self->getJsonBody($req);
my $replace = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($replace);

View File

@ -91,7 +91,7 @@ sub findOidcRpByClientId {
sub addOidcRp {
my ( $self, $req ) = @_;
my $add = $self->getJsonBody($req);
my $add = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($add);
@ -161,7 +161,7 @@ sub updateOidcRp {
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
my $update = $self->getJsonBody($req);
my $update = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($update);
@ -199,7 +199,7 @@ sub replaceOidcRp {
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
my $replace = $self->getJsonBody($req);
my $replace = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($replace);

View File

@ -85,7 +85,7 @@ sub findSamlSpByEntityId {
sub addSamlSp {
my ( $self, $req ) = @_;
my $add = $self->getJsonBody($req);
my $add = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($add);
@ -140,7 +140,7 @@ sub replaceSamlSp {
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
my $replace = $self->getJsonBody($req);
my $replace = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($replace);
@ -180,7 +180,7 @@ sub updateSamlSp {
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
my $update = $self->getJsonBody($req);
my $update = $req->jsonBodyToObj;
return $self->sendError( $req, "Invalid input: " . $req->error, 400 )
unless ($update);