Add minimum length as const in ApiKeyValidationCheck

pull/1660/head
Bogdan 2 years ago
parent 10bbaee55d
commit befb354913

@ -10,10 +10,12 @@ 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;
public ApiKeyValidationCheck(IConfigFileProvider configFileProvider, ILocalizationService localizationService, Logger logger)
public ApiKeyValidationCheck(IConfigFileProvider configFileProvider, Logger logger, ILocalizationService localizationService)
: base(localizationService)
{
_configFileProvider = configFileProvider;
@ -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());

@ -23,7 +23,7 @@
"Analytics": "Analytics",
"AnalyticsEnabledHelpText": "Send anonymous usage and error information to Prowlarr's servers. This includes information on your browser, which Prowlarr WebUI pages you use, error reporting as well as OS and runtime version. We will use this information to prioritize features and bug fixes.",
"ApiKey": "API Key",
"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",
"AppProfileDeleteConfirm": "Are you sure you want to delete {0}?",

Loading…
Cancel
Save