Co-authored-by: ilike2burnthing <59480337+ilike2burnthing@users.noreply.github.com>pull/1467/head
parent
5f26287234
commit
26bea14137
@ -0,0 +1,31 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Annotations;
|
||||||
|
using NzbDrone.Core.Indexers.Settings;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Indexers.Definitions.Gazelle;
|
||||||
|
|
||||||
|
public class GazelleUserPassOrCookieValidator<T> : NoAuthSettingsValidator<T>
|
||||||
|
where T : GazelleUserPassOrCookieSettings
|
||||||
|
{
|
||||||
|
public GazelleUserPassOrCookieValidator()
|
||||||
|
{
|
||||||
|
RuleFor(c => c.Username).NotEmpty().When(c => c.Cookie.IsNullOrWhiteSpace());
|
||||||
|
RuleFor(c => c.Password).NotEmpty().When(c => c.Cookie.IsNullOrWhiteSpace());
|
||||||
|
RuleFor(c => c.Cookie).NotEmpty().When(c => c.Username.IsNullOrWhiteSpace() && c.Password.IsNullOrWhiteSpace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GazelleUserPassOrCookieSettings : GazelleSettings
|
||||||
|
{
|
||||||
|
private static readonly GazelleUserPassOrCookieValidator<GazelleUserPassOrCookieSettings> Validator = new ();
|
||||||
|
|
||||||
|
[FieldDefinition(4, Label = "Cookie", HelpText = "Use the Cookie field only if 2FA is enabled for your account, leave it empty otherwise.", Privacy = PrivacyLevel.Password)]
|
||||||
|
public string Cookie { get; set; }
|
||||||
|
|
||||||
|
public override NzbDroneValidationResult Validate()
|
||||||
|
{
|
||||||
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue