From ec973917b4f12fa1da4341e9a6f09eb1947fed78 Mon Sep 17 00:00:00 2001 From: smcpeck Date: Mon, 27 Feb 2017 23:30:03 -0600 Subject: [PATCH] Tweaked ApiRequest behavior on non-200 responses; think it was breaking login. :-" --- Ombi.Api/ApiRequest.cs | 20 +++++++++++--------- Ombi.UI/Modules/UserLoginModule.cs | 2 -- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Ombi.Api/ApiRequest.cs b/Ombi.Api/ApiRequest.cs index 65d2455fd..9566d2be0 100644 --- a/Ombi.Api/ApiRequest.cs +++ b/Ombi.Api/ApiRequest.cs @@ -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(response.Content); - return result; + return DeserializeXml(response.Content); + else + throw new Exception($"Got StatusCode={response.StatusCode} for {baseUri}."); + } public T ExecuteJson(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(response.Content, _settings); - return result; + return JsonConvert.DeserializeObject(response.Content, _settings); + else + throw new Exception($"Got StatusCode={response.StatusCode} for {baseUri}."); } private T DeserializeXml(string input) diff --git a/Ombi.UI/Modules/UserLoginModule.cs b/Ombi.UI/Modules/UserLoginModule.cs index 1fd82cb2e..1f9250ad9 100644 --- a/Ombi.UI/Modules/UserLoginModule.cs +++ b/Ombi.UI/Modules/UserLoginModule.cs @@ -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 LoginUser()