mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 09:55:18 +00:00
Improve conditions
This commit is contained in:
parent
67be7f3991
commit
caf90b537b
@ -523,12 +523,11 @@ export class WazuhApiCtrl {
|
||||
try {
|
||||
const api = await this.wzWrapper.getWazuhConfigurationById(id);
|
||||
|
||||
let devtools = false;
|
||||
if(data.devTools){
|
||||
const devTools = !!(data || {}).devTools;
|
||||
if (devTools) {
|
||||
delete data.devTools;
|
||||
devtools = true;
|
||||
}
|
||||
|
||||
|
||||
if (api.error_code > 1) {
|
||||
//Can not connect to elasticsearch
|
||||
return ErrorResponse(
|
||||
@ -561,27 +560,17 @@ export class WazuhApiCtrl {
|
||||
const response = await needle(method, fullUrl, data, options);
|
||||
|
||||
if (
|
||||
response &&
|
||||
response.body &&
|
||||
!response.body.error &&
|
||||
response.body.data
|
||||
!((response || {}).body || {}).error &&
|
||||
((response || {}).body || {}).data
|
||||
) {
|
||||
cleanKeys(response);
|
||||
return reply(response.body);
|
||||
}
|
||||
|
||||
if (
|
||||
response &&
|
||||
response.body &&
|
||||
response.body.error &&
|
||||
devtools
|
||||
) {
|
||||
if (((response || {}).body || {}).error && devTools) {
|
||||
return reply(response.body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
throw ((response || {}).body || {}).error &&
|
||||
((response || {}).body || {}).message
|
||||
? { message: response.body.message, code: response.body.error }
|
||||
@ -596,8 +585,6 @@ export class WazuhApiCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This performs a generic request and returs its response
|
||||
* @param {String} method Method: GET, PUT, POST, DELETE
|
||||
@ -689,7 +676,6 @@ export class WazuhApiCtrl {
|
||||
reply
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
return this.makeRequest(
|
||||
req.payload.method,
|
||||
|
Loading…
Reference in New Issue
Block a user