mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-18 21:55:12 -04:00
f0c7d13b20
Use named tokens for backend translations (cherry picked from commit 11f96c31048c2d1aafca0c91736d439f7f9a95a8)
39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using NLog;
|
|
using NzbDrone.Core.Configuration;
|
|
using NzbDrone.Core.Configuration.Events;
|
|
using NzbDrone.Core.Lifecycle;
|
|
using NzbDrone.Core.Localization;
|
|
|
|
namespace NzbDrone.Core.HealthCheck.Checks
|
|
{
|
|
[CheckOn(typeof(ApplicationStartedEvent))]
|
|
[CheckOn(typeof(ConfigSavedEvent))]
|
|
public class ApiKeyValidationCheck : HealthCheckBase
|
|
{
|
|
private const int MinimumLength = 20;
|
|
|
|
private readonly IConfigFileProvider _configFileProvider;
|
|
private readonly Logger _logger;
|
|
|
|
public ApiKeyValidationCheck(IConfigFileProvider configFileProvider, Logger logger, ILocalizationService localizationService)
|
|
: base(localizationService)
|
|
{
|
|
_configFileProvider = configFileProvider;
|
|
_logger = logger;
|
|
}
|
|
|
|
public override HealthCheck Check()
|
|
{
|
|
if (_configFileProvider.ApiKey.Length < MinimumLength)
|
|
{
|
|
_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", new Dictionary<string, object> { { "length", MinimumLength } }), "#invalid-api-key");
|
|
}
|
|
|
|
return new HealthCheck(GetType());
|
|
}
|
|
}
|
|
}
|