From e5f9855640856e31db7f49184b8bf3e22fc8090e Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 13 May 2023 15:23:01 +0300 Subject: [PATCH] Add minimum length as const in ApiKeyValidationCheck (cherry picked from commit b06269544cfa11015f3fb938fd8c2ef07d9cac4a) Closes #3755 --- .../HealthCheck/Checks/ApiKeyValidationCheck.cs | 8 +++++--- src/NzbDrone.Core/Localization/Core/en.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/HealthCheck/Checks/ApiKeyValidationCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/ApiKeyValidationCheck.cs index 77e76d2a3..eb0e38014 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/ApiKeyValidationCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/ApiKeyValidationCheck.cs @@ -10,6 +10,8 @@ namespace NzbDrone.Core.HealthCheck.Checks [CheckOn(typeof(ConfigSavedEvent))] public class ApiKeyValidationCheck : HealthCheckBase { + private const int MinimumLength = 20; + private readonly IConfigFileProvider _configFileProvider; private readonly Logger _logger; @@ -22,11 +24,11 @@ namespace NzbDrone.Core.HealthCheck.Checks public override HealthCheck Check() { - if (_configFileProvider.ApiKey.Length < 20) + if (_configFileProvider.ApiKey.Length < MinimumLength) { - _logger.Warn("Please update your API key to be at least 20 characters long. You can do this via settings or the config file"); + _logger.Warn("Please update your API key to be at least {0} characters long. You can do this via settings or the config file", MinimumLength); - return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("ApiKeyValidationHealthCheckMessage"), "#invalid-api-key"); + return new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format(_localizationService.GetLocalizedString("ApiKeyValidationHealthCheckMessage"), MinimumLength), "#invalid-api-key"); } return new HealthCheck(GetType()); diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 4ea0c4962..da606d4ea 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -66,7 +66,7 @@ "AnchorTooltip": "This file is already in your library for a release you are currently importing", "AnyReleaseOkHelpText": "Lidarr will automatically switch to the release best matching downloaded tracks", "ApiKeyHelpTextWarning": "Requires restart to take effect", - "ApiKeyValidationHealthCheckMessage": "Please update your API key to be at least 20 characters long. You can do this via settings or the config file", + "ApiKeyValidationHealthCheckMessage": "Please update your API key to be at least {0} characters long. You can do this via settings or the config file", "AppDataDirectory": "AppData directory", "AppDataLocationHealthCheckMessage": "Updating will not be possible to prevent deleting AppData on Update", "ApplicationURL": "Application URL",