From 8caac538c9bf6596f97599ff0549e9150a682008 Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 30 Oct 2023 13:39:50 +0100 Subject: [PATCH] https://github.com/C9Glax/tranga-website/issues/19 Send a badrequest response if not a valid libraryconnector --- Tranga/Server.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Tranga/Server.cs b/Tranga/Server.cs index 333ddda..1fbe552 100644 --- a/Tranga/Server.cs +++ b/Tranga/Server.cs @@ -401,8 +401,7 @@ public class Server : GlobalBase break; case "LibraryConnectors/Update": if (!requestVariables.TryGetValue("libraryConnector", out string? libraryConnectorStr) || - !Enum.TryParse(libraryConnectorStr, - out LibraryConnector.LibraryType libraryConnectorType)) + !Enum.TryParse(libraryConnectorStr, out LibraryConnector.LibraryType libraryConnectorType)) { SendResponse(HttpStatusCode.BadRequest, response); break; @@ -419,10 +418,7 @@ public class Server : GlobalBase } AddLibraryConnector(new Kavita(this, kavitaUrl, kavitaUsername, kavitaPassword)); SendResponse(HttpStatusCode.Accepted, response); - break; - } - - if (libraryConnectorType is LibraryConnector.LibraryType.Komga) + }else if (libraryConnectorType is LibraryConnector.LibraryType.Komga) { if (!requestVariables.TryGetValue("komgaUrl", out string? komgaUrl) || !requestVariables.TryGetValue("komgaAuth", out string? komgaAuth)) @@ -432,7 +428,10 @@ public class Server : GlobalBase } AddLibraryConnector(new Komga(this, komgaUrl, komgaAuth)); SendResponse(HttpStatusCode.Accepted, response); - break; + } + else + { + SendResponse(HttpStatusCode.BadRequest, response); } break; case "LogMessages":