mirror of https://github.com/Icinga/icinga2.git
Unify the JSON structures of responses to authorized and unauthorized requests
refs #4984 fixes #4988 Signed-off-by: Michael Friedrich <michael.friedrich@icinga.com>
This commit is contained in:
parent
363a7f9dac
commit
3cc8982053
|
@ -186,15 +186,10 @@ void HttpServerConnection::ProcessMessageAsync(HttpRequest& request)
|
||||||
response.AddHeader("WWW-Authenticate", "Basic realm=\"Icinga 2\"");
|
response.AddHeader("WWW-Authenticate", "Basic realm=\"Icinga 2\"");
|
||||||
|
|
||||||
if (request.Headers->Get("accept") == "application/json") {
|
if (request.Headers->Get("accept") == "application/json") {
|
||||||
Dictionary::Ptr result1 = new Dictionary();
|
|
||||||
|
|
||||||
result1->Set("info", "Unauthorized. Please check your user credentials.");
|
|
||||||
|
|
||||||
Array::Ptr results = new Array();
|
|
||||||
results->Add(result1);
|
|
||||||
|
|
||||||
Dictionary::Ptr result = new Dictionary();
|
Dictionary::Ptr result = new Dictionary();
|
||||||
result->Set("results", results);
|
|
||||||
|
result->Set("error", 401);
|
||||||
|
result->Set("status", "Unauthorized. Please check your user credentials.");
|
||||||
|
|
||||||
HttpUtility::SendJsonBody(response, result);
|
HttpUtility::SendJsonBody(response, result);
|
||||||
} else {
|
} else {
|
||||||
|
@ -213,15 +208,10 @@ void HttpServerConnection::ProcessMessageAsync(HttpRequest& request)
|
||||||
String errorInfo = DiagnosticInformation(ex);
|
String errorInfo = DiagnosticInformation(ex);
|
||||||
|
|
||||||
if (request.Headers->Get("accept") == "application/json") {
|
if (request.Headers->Get("accept") == "application/json") {
|
||||||
Dictionary::Ptr result1 = new Dictionary();
|
|
||||||
|
|
||||||
result1->Set("info", errorInfo);
|
|
||||||
|
|
||||||
Array::Ptr results = new Array();
|
|
||||||
results->Add(result1);
|
|
||||||
|
|
||||||
Dictionary::Ptr result = new Dictionary();
|
Dictionary::Ptr result = new Dictionary();
|
||||||
result->Set("results", results);
|
|
||||||
|
result->Set("error", 503);
|
||||||
|
result->Set("status", errorInfo);
|
||||||
|
|
||||||
HttpUtility::SendJsonBody(response, result);
|
HttpUtility::SendJsonBody(response, result);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue