mirror of
https://github.com/Jackett/Jackett
synced 2025-02-24 15:21:06 +00:00
Implement not local/recaptcha login for torrentday
This commit is contained in:
parent
d1ff05ac13
commit
ac0842f786
5 changed files with 90 additions and 15 deletions
|
@ -243,4 +243,18 @@ hr {
|
|||
|
||||
.downloadcolumn {
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
pre {
|
||||
display: block;
|
||||
padding: 3px;
|
||||
margin: 0 0 0px;
|
||||
font-size: 13px;
|
||||
line-height: 1.42857143;
|
||||
color: #333;
|
||||
word-break: break-all;
|
||||
word-wrap: break-word;
|
||||
background-color: transparent;
|
||||
border: 0px;
|
||||
border-radius: 0px;
|
||||
}
|
|
@ -3,6 +3,9 @@
|
|||
reloadIndexers();
|
||||
loadJackettSettings();
|
||||
|
||||
window.jackettIsLocal = window.location.hostname === 'localhost' ||
|
||||
window.location.hostname === '127.0.0.1';
|
||||
|
||||
$('body').on('click', '.downloadlink', function (e, b) {
|
||||
$(e.target).addClass('jackettdownloaded');
|
||||
});
|
||||
|
@ -81,7 +84,7 @@ $("#jackett-show-releases").click(function () {
|
|||
var count = 0;
|
||||
this.api().columns().every(function () {
|
||||
count++;
|
||||
if (count === 5 || count ===7) {
|
||||
if (count === 5 || count === 7) {
|
||||
var column = this;
|
||||
var select = $('<select><option value=""></option></select>')
|
||||
.appendTo($(column.footer()).empty())
|
||||
|
@ -131,7 +134,7 @@ $("#change-jackett-port").click(function () {
|
|||
var jsonObject = {
|
||||
port: jackett_port,
|
||||
external: jackett_external,
|
||||
blackholedir: $("#jackett-savedir").val()
|
||||
blackholedir: $("#jackett-savedir").val()
|
||||
};
|
||||
var jqxhr = $.post("/admin/set_config", JSON.stringify(jsonObject), function (data) {
|
||||
if (data.result == "error") {
|
||||
|
@ -293,21 +296,37 @@ function populateConfigItems(configForm, config) {
|
|||
}
|
||||
var $formItemContainer = configForm.find(".config-setup-form");
|
||||
$formItemContainer.empty();
|
||||
var setupItemTemplate = Handlebars.compile($("#setup-item").html());
|
||||
|
||||
$('.jackettrecaptcha').remove();
|
||||
|
||||
var hasReacaptcha = false;
|
||||
var captchaItem = null;
|
||||
for (var i = 0; i < config.length; i++) {
|
||||
var item = config[i];
|
||||
var setupValueTemplate = Handlebars.compile($("#setup-item-" + item.type).html());
|
||||
|
||||
|
||||
item.value_element = setupValueTemplate(item);
|
||||
var template = setupItemTemplate(item);
|
||||
if (config[i].type === 'recaptcha') {
|
||||
hasReacaptcha = true;
|
||||
captchaItem = config[i];
|
||||
}
|
||||
}
|
||||
|
||||
var setupItemTemplate = Handlebars.compile($("#setup-item").html());
|
||||
if (hasReacaptcha && !window.jackettIsLocal) {
|
||||
var setupValueTemplate = Handlebars.compile($("#setup-item-nonlocalrecaptcha").html());
|
||||
captchaItem.value_element = setupValueTemplate(captchaItem);
|
||||
var template = setupItemTemplate(captchaItem);
|
||||
$formItemContainer.append(template);
|
||||
} else {
|
||||
|
||||
if (item.type === 'recaptcha') {
|
||||
grecaptcha.render($('.jackettrecaptcha')[0], {
|
||||
'sitekey': item.sitekey
|
||||
});
|
||||
for (var i = 0; i < config.length; i++) {
|
||||
var item = config[i];
|
||||
var setupValueTemplate = Handlebars.compile($("#setup-item-" + item.type).html());
|
||||
item.value_element = setupValueTemplate(item);
|
||||
var template = setupItemTemplate(item);
|
||||
$formItemContainer.append(template);
|
||||
if (item.type === 'recaptcha') {
|
||||
grecaptcha.render($('.jackettrecaptcha')[0], {
|
||||
'sitekey': item.sitekey
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +357,11 @@ function getConfigModalJson(configForm) {
|
|||
itemEntry.value = $el.find(".setup-item-inputbool input").is(":checked");
|
||||
break;
|
||||
case "recaptcha":
|
||||
itemEntry.value = $('.g-recaptcha-response').val();
|
||||
if (window.jackettIsLocal) {
|
||||
itemEntry.value = $('.g-recaptcha-response').val();
|
||||
} else {
|
||||
itemEntry.cookie = $el.find(".setup-item-recaptcha input").val();
|
||||
}
|
||||
break;
|
||||
}
|
||||
configJson.push(itemEntry)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<script src="/libs/handlebarsmoment.js"></script>
|
||||
<script src="/bootstrap/bootstrap.min.js"></script>
|
||||
<script src="/libs/bootstrap-notify.js"></script>
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
|
||||
|
||||
<link href="/bootstrap/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="/animate.css" rel="stylesheet">
|
||||
|
@ -21,6 +21,14 @@
|
|||
<link href="/css/jquery.dataTables.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/font-awesome.min.css">
|
||||
|
||||
|
||||
<script id="setup-item-nonlocalrecaptcha" type="text/x-handlebars-template">
|
||||
<div class="setup-item-recaptcha">
|
||||
<p>This site requires you to enter a ReCaptcha however this only works when accessing Jackett via localhost or 127.0.0.1. If you cannot access Jackett using that hostname then alternatively you can enter the cookie for the site manually. <a href="https://github.com/zone117x/Jackett/wiki/Finding-cookies" target="_blank">See here</a> on how get the cookies.</p>
|
||||
<div class="setup-item-label">Full cookie header</div>
|
||||
<input class="form-control" type="text" value="" />
|
||||
</div>
|
||||
</script>
|
||||
<script id="setup-item" type="text/x-handlebars-template">
|
||||
<div class="setup-item form-group" data-id="{{id}}" data-value="{{value}}" data-type="{{type}}">
|
||||
<div class="setup-item-label">{{name}}</div>
|
||||
|
|
|
@ -103,6 +103,28 @@ namespace Jackett.Indexers
|
|||
{ "g-recaptcha-response", configData.Captcha.Value }
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(configData.Captcha.Cookie))
|
||||
{
|
||||
// Cookie was manually supplied
|
||||
CookieHeader = configData.Captcha.Cookie;
|
||||
try
|
||||
{
|
||||
var results = await PerformQuery(new TorznabQuery());
|
||||
if (results.Count() == 0)
|
||||
{
|
||||
throw new Exception("Your cookie did not work");
|
||||
}
|
||||
|
||||
SaveConfig();
|
||||
IsConfigured = true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
IsConfigured = false;
|
||||
throw new Exception("Your cookie did not work: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, configData.CookieHeader.Value, true, SiteLink, LoginUrl);
|
||||
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
||||
{
|
||||
|
@ -110,6 +132,12 @@ namespace Jackett.Indexers
|
|||
var messageEl = dom["#login"];
|
||||
messageEl.Children("form").Remove();
|
||||
var errorMessage = messageEl.Text().Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(errorMessage))
|
||||
{
|
||||
errorMessage = dom.Text();
|
||||
}
|
||||
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace Jackett.Models.IndexerConfig
|
|||
break;
|
||||
case ItemType.Recaptcha:
|
||||
((RecaptchaItem)item).Value = arrItem.Value<string>("value");
|
||||
((RecaptchaItem)item).Cookie = arrItem.Value<string>("cookie");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +168,7 @@ namespace Jackett.Models.IndexerConfig
|
|||
{
|
||||
public string SiteKey { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Cookie { get; set; }
|
||||
public StringItem()
|
||||
{
|
||||
ItemType = ConfigurationData.ItemType.InputString;
|
||||
|
|
Loading…
Reference in a new issue