Add minimum length as const in ApiKeyValidationCheck

(cherry picked from commit b06269544cfa11015f3fb938fd8c2ef07d9cac4a)

Closes #2565
pull/2573/head
Bogdan 1 year ago
parent d1aff31593
commit 1db333088a

@ -10,6 +10,8 @@ namespace NzbDrone.Core.HealthCheck.Checks
[CheckOn(typeof(ConfigSavedEvent))] [CheckOn(typeof(ConfigSavedEvent))]
public class ApiKeyValidationCheck : HealthCheckBase public class ApiKeyValidationCheck : HealthCheckBase
{ {
private const int MinimumLength = 20;
private readonly IConfigFileProvider _configFileProvider; private readonly IConfigFileProvider _configFileProvider;
private readonly Logger _logger; private readonly Logger _logger;
@ -22,11 +24,11 @@ namespace NzbDrone.Core.HealthCheck.Checks
public override HealthCheck Check() 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()); return new HealthCheck(GetType());

@ -31,7 +31,7 @@
"AnalyticsEnabledHelpTextWarning": "Requires restart to take effect", "AnalyticsEnabledHelpTextWarning": "Requires restart to take effect",
"AnyEditionOkHelpText": "Readarr will automatically switch to the edition best matching downloaded files", "AnyEditionOkHelpText": "Readarr will automatically switch to the edition best matching downloaded files",
"ApiKeyHelpTextWarning": "Requires restart to take effect", "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", "AppDataDirectory": "AppData directory",
"AppDataLocationHealthCheckMessage": "Updating will not be possible to prevent deleting AppData on Update", "AppDataLocationHealthCheckMessage": "Updating will not be possible to prevent deleting AppData on Update",
"ApplicationURL": "Application URL", "ApplicationURL": "Application URL",

Loading…
Cancel
Save