add return error if group = 0 on new agent api

This commit is contained in:
marcos 2020-05-18 10:15:20 +02:00
parent e8dd2b13c7
commit 347f6b1bf3
1 changed files with 6 additions and 0 deletions

View File

@ -1506,6 +1506,12 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3)
return;
}
if ((int) $other['data'][3] == 0) {
$agent_creation_error = __('The agent could not be created, for security reasons use a group another than 0');
returnError('generic error', $agent_creation_error);
return;
}
$alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $other['data'][0])));
$direccion_agente = io_safe_input($other['data'][1]);
$nombre_agente = hash('sha256', $direccion_agente.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000)));