Better Captcha message.

pull/2/head
Taloth Saldono 8 years ago
parent 28f6777f9a
commit 7f6101a6bc

@ -15,5 +15,10 @@ namespace NzbDrone.Core.Http.CloudFlare
Response = response;
CaptchaRequest = captchaRequest;
}
public bool IsExpired
{
get { return Response.Request.Cookies.ContainsKey("cf_clearance"); }
}
}
}

@ -27,7 +27,7 @@ namespace NzbDrone.Core.Http.CloudFlare
{
if (response.StatusCode == HttpStatusCode.Forbidden && response.Content.Contains(_cloudFlareChallengeScript))
{
_logger.Error("CloudFlare CAPTCHA block on {0}", response.Request.Url);
_logger.Debug("CloudFlare CAPTCHA block on {0}", response.Request.Url);
throw new CloudFlareCaptchaException(response, CreateCaptchaRequest(response));
}

@ -246,6 +246,18 @@ namespace NzbDrone.Core.Indexers
_indexerStatusService.RecordFailure(Definition.Id);
_logger.Warn("Invalid API Key for {0} {1}", this, url);
}
catch (CloudFlareCaptchaException ex)
{
_indexerStatusService.RecordFailure(Definition.Id);
if (ex.IsExpired)
{
_logger.Error(ex, "Expired CAPTCHA token for {0}, please refresh in indexer settings.", this);
}
else
{
_logger.Error(ex, "CAPTCHA token required for {0}, check indexer settings.", this);
}
}
catch (IndexerException ex)
{
_indexerStatusService.RecordFailure(Definition.Id);
@ -314,9 +326,16 @@ namespace NzbDrone.Core.Indexers
{
_logger.Warn("Request limit reached");
}
catch (CloudFlareCaptchaException)
catch (CloudFlareCaptchaException ex)
{
return new ValidationFailure("CaptchaToken", "Site protected by CloudFlare CAPTCHA. Valid CAPTCHA token required.");
if (ex.IsExpired)
{
return new ValidationFailure("CaptchaToken", "CloudFlare CAPTCHA token expired, please Refresh.");
}
else
{
return new ValidationFailure("CaptchaToken", "Site protected by CloudFlare CAPTCHA. Valid CAPTCHA token required.");
}
}
catch (UnsupportedFeedException ex)
{

@ -3,12 +3,13 @@
<div class="col-sm-5">
<div class="input-group">
<input type="text" name="fields.{{order}}.value" validation-name="{{name}}" spellcheck="false" class="form-control x-captcha" readonly />
<input type="text" name="fields.{{order}}.value" validation-name="{{name}}" spellcheck="false" class="form-control x-captcha" readonly placeholder="(optional)" />
<span class="input-group-btn"><button class="btn btn-primary x-captcha-refresh" title="Refresh CAPTCHA Token"><i class="icon-sonarr-refresh" /></button></span>
</div>
</div>
<span class="col-sm-1 help-inline">
<i class="icon-sonarr-form-warning" title="Expires periodically and will need to be refreshed. Refreshing the CAPTCHA Token will embed a temporary Google reCaptcha widget on this page."/>
<i class="icon-sonarr-form-warning" title="Expires periodically and will need to be refreshed."/>
<i class="icon-sonarr-form-warning" title="Refreshing the CAPTCHA Token will embed a temporary Google reCaptcha widget on this page."/>
</span>
</div>

Loading…
Cancel
Save