diff --git a/pandora_console/include/api.php b/pandora_console/include/api.php index 85bc78c6e8..e1d2fea2df 100644 --- a/pandora_console/include/api.php +++ b/pandora_console/include/api.php @@ -275,7 +275,7 @@ if ($correctLogin) { break; case 'event': - // Preventive check for users if not available write events + // Preventive check for users if not available write events. if (! check_acl($config['id_user'], $event['id_grupo'], 'EW')) { return false; } @@ -322,7 +322,10 @@ if ($correctLogin) { sleep(15); // Protection on DoS attacks. - echo 'auth error'; + returnError( + 'auth_error', + $returnType + ); } // Logout. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index d9d3d16ee6..6167cccc68 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -108,6 +108,7 @@ function returnError($typeError, $returnType='string') { switch ($typeError) { case 'no_set_no_get_no_help': + http_response_code(403); returnData( $returnType, [ @@ -118,6 +119,7 @@ function returnError($typeError, $returnType='string') break; case 'no_exist_operation': + http_response_code(404); returnData( $returnType, [ @@ -128,6 +130,7 @@ function returnError($typeError, $returnType='string') break; case 'id_not_found': + http_response_code(403); returnData( $returnType, [ @@ -138,6 +141,7 @@ function returnError($typeError, $returnType='string') break; case 'not_allowed_operation_cluster': + http_response_code(403); returnData( $returnType, [ @@ -148,6 +152,7 @@ function returnError($typeError, $returnType='string') break; case 'forbidden': + http_response_code(403); returnData( $returnType, [ @@ -168,6 +173,7 @@ function returnError($typeError, $returnType='string') break; case 'centralized': + http_response_code(403); returnData( $returnType, [ @@ -177,6 +183,17 @@ function returnError($typeError, $returnType='string') ); break; + case 'auth_error': + http_response_code(403); + returnData( + $returnType, + [ + 'type' => 'string', + 'data' => __('Auth error'), + ] + ); + break; + default: returnData( $returnType,