Tweaked ApiRequest behavior on non-200 responses; think it was breaking login. :-"

pull/1199/head
smcpeck 8 years ago
parent 231a525109
commit ec973917b4

@ -66,10 +66,11 @@ namespace Ombi.Api
throw new ApiRequestException(message, response.ErrorException);
}
if (response.StatusCode != HttpStatusCode.OK)
return default(T);
else
if (response.StatusCode == HttpStatusCode.OK)
return response.Data;
else
throw new Exception($"Got StatusCode={response.StatusCode} for {baseUri}.");
}
public IRestResponse Execute(IRestRequest request, Uri baseUri)
@ -92,10 +93,11 @@ namespace Ombi.Api
throw new ApiRequestException(message, response.ErrorException);
}
T result = default(T);
if (response.StatusCode == HttpStatusCode.OK)
result = DeserializeXml<T>(response.Content);
return result;
return DeserializeXml<T>(response.Content);
else
throw new Exception($"Got StatusCode={response.StatusCode} for {baseUri}.");
}
public T ExecuteJson<T>(IRestRequest request, Uri baseUri) where T : new()
@ -111,10 +113,10 @@ namespace Ombi.Api
throw new ApiRequestException(message, response.ErrorException);
}
T result = default(T);
if (response.StatusCode == HttpStatusCode.OK)
result = JsonConvert.DeserializeObject<T>(response.Content, _settings);
return result;
return JsonConvert.DeserializeObject<T>(response.Content, _settings);
else
throw new Exception($"Got StatusCode={response.StatusCode} for {baseUri}.");
}
private T DeserializeXml<T>(string input)

@ -373,7 +373,6 @@ namespace Ombi.UI.Modules
return Response.AsJson(new { result = false, message = Resources.UI.UserLogin_IncorrectUserPass });
}
var m = await AuthenticationSetup(userId, username, dateTimeOffset, loginGuid, isOwner, plexSettings.Enable, embySettings.Enable);
var landingSettings = await LandingPageSettings.GetSettingsAsync();
@ -397,7 +396,6 @@ namespace Ombi.UI.Modules
return CustomModuleExtensions.LoginAndRedirect(this, m.LoginGuid, null, retVal.ToString());
}
return Response.AsJson(new { result = true, url = retVal.ToString() });
}
private async Task<Response> LoginUser()

Loading…
Cancel
Save