Better Captcha message.

This commit is contained in:
Taloth Saldono 2016-08-20 19:37:31 +02:00
parent 28f6777f9a
commit 7f6101a6bc
4 changed files with 30 additions and 5 deletions

View File

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

View File

@ -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));
}

View File

@ -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,10 +326,17 @@ namespace NzbDrone.Core.Indexers
{
_logger.Warn("Request limit reached");
}
catch (CloudFlareCaptchaException)
catch (CloudFlareCaptchaException ex)
{
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)
{
_logger.Warn(ex, "Indexer feed is not supported");

View File

@ -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>