From df1ecd7318d26d29cd2f95eb14cffaec91264129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Mon, 27 Jun 2016 06:08:25 +0000 Subject: [PATCH] Return JSON response instead of error when no sessions are found (#1043) --- .../lib/Lemonldap/NG/Manager/Sessions.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm index f5b248913..e94021a6f 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm @@ -139,9 +139,16 @@ sub sessions { Lemonldap::NG::Common::Apache::Session->$function( $moduleOptions, $firstFilter, $filters{$firstFilter}, @fields ); - # TODO: change this - return $self->sendError( $req, 'No sessions', 200 ) - unless ( $res and %$res ); + return $self->sendJSONresponse( + $req, + { + result => 1, + count => 0, + total => 0, + values => [] + } + ) unless ( $res and %$res ); + delete $filters{$firstFilter}; foreach my $k ( keys %filters ) { $filters{$k} =~ s/\*/\.\*/g;