Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Updated error message for incorrect api key.

nzbdav-devbf817145a511
diff --git a/backend/Api/Controllers/BaseApiController.cs b/backend/Api/Controllers/BaseApiController.cs
index 155081fe..57d6aef5 100644
--- a/backend/Api/Controllers/BaseApiController.cs
+++ b/backend/Api/Controllers/BaseApiController.cs
@@ -19,8 +19,10 @@ public abstract class BaseApiController : ControllerBase
if (RequiresAuthentication)
{
var apiKey = HttpContext.GetRequestApiKey();
- if (apiKey != EnvironmentUtil.GetVariable("FRONTEND_BACKEND_API_KEY"))
+ if (apiKey == null)
throw new UnauthorizedAccessException("API Key Required");
+ if (apiKey != EnvironmentUtil.GetVariable("FRONTEND_BACKEND_API_KEY"))
+ throw new UnauthorizedAccessException("API Key Incorrect");
}
return await HandleRequest();
diff --git a/backend/Api/SabControllers/SabApiController.cs b/backend/Api/SabControllers/SabApiController.cs
index d4b949e4..3d77a4a4 100644
--- a/backend/Api/SabControllers/SabApiController.cs
+++ b/backend/Api/SabControllers/SabApiController.cs
@@ -112,8 +112,10 @@ public class SabApiController(
configManager.GetApiKey(),
EnvironmentUtil.GetVariable("FRONTEND_BACKEND_API_KEY")
);
- if (!isValidKey.HasValue || !isValidKey.Value)
+ if (!isValidKey.HasValue)
throw new UnauthorizedAccessException("API Key Required");
+ if (!isValidKey.Value)
+ throw new UnauthorizedAccessException("API Key Incorrect");
}
return Handle();