mirror of https://github.com/MISP/MISP
fix: [UI] Show correct error message for get remote user
parent
9ccd157d3d
commit
1571ab90ae
|
@ -4433,7 +4433,7 @@ class Server extends AppModel
|
|||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return array|int|null
|
||||
* @return array|null
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function getRemoteUser($id)
|
||||
|
@ -4464,12 +4464,12 @@ class Server extends AppModel
|
|||
return $results;
|
||||
} catch (HttpSocketHttpException $e) {
|
||||
$this->logException('Could not fetch remote user account.', $e);
|
||||
return $e->getCode();
|
||||
return ['error' => $e->getCode()];
|
||||
} catch (Exception $e) {
|
||||
$this->logException('Could not fetch remote user account.', $e);
|
||||
$message = __('Could not fetch remote user account.');
|
||||
$this->loadLog()->createLogEntry('SYSTEM', 'error', 'Server', $id, 'Error: ' . $message);
|
||||
return $message;
|
||||
return ['error' => $message];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3282,23 +3282,25 @@ function getRemoteSyncUser(id) {
|
|||
var resultContainer = $("#sync_user_test_" + id);
|
||||
$.ajax({
|
||||
url: baseurl + '/servers/getRemoteUser/' + id,
|
||||
type:'GET',
|
||||
type: 'GET',
|
||||
beforeSend: function () {
|
||||
resultContainer.html('Running test...');
|
||||
resultContainer.text('Running test...');
|
||||
},
|
||||
error: function() {
|
||||
resultContainer.html('Internal error.');
|
||||
resultContainer.html('<span class="red bold">Internal error</span>');
|
||||
},
|
||||
success: function(response) {
|
||||
resultContainer.empty();
|
||||
if (typeof response !== 'object') {
|
||||
resultContainer.html('<span class="red bold">Internal error</span>');
|
||||
} else if ("error" in response) {
|
||||
resultContainer.append(
|
||||
$('<span>')
|
||||
.attr('class', 'red bold')
|
||||
.text('Error')
|
||||
.attr('class', 'red bold')
|
||||
.text('Error')
|
||||
).append(
|
||||
$('<span>')
|
||||
.text(': #' + response)
|
||||
.text(': #' + response)
|
||||
);
|
||||
} else {
|
||||
Object.keys(response).forEach(function(key) {
|
||||
|
|
Loading…
Reference in New Issue