mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 11:49:01 +03:00
Merge pull request #4731 from ngosang/webui_username
Check WebUI username and password length. Closes #4191
This commit is contained in:
commit
87c32ccb98
4 changed files with 27 additions and 15 deletions
|
@ -519,7 +519,6 @@ void options_imp::saveOptions()
|
||||||
pref->setWebUiHttpsKey(m_sslKey);
|
pref->setWebUiHttpsKey(m_sslKey);
|
||||||
}
|
}
|
||||||
pref->setWebUiUsername(webUiUsername());
|
pref->setWebUiUsername(webUiUsername());
|
||||||
// FIXME: Check that the password is valid (not empty at least)
|
|
||||||
pref->setWebUiPassword(webUiPassword());
|
pref->setWebUiPassword(webUiPassword());
|
||||||
pref->setWebUiLocalAuthEnabled(!checkBypassLocalAuth->isChecked());
|
pref->setWebUiLocalAuthEnabled(!checkBypassLocalAuth->isChecked());
|
||||||
// DynDNS
|
// DynDNS
|
||||||
|
@ -1024,6 +1023,10 @@ void options_imp::on_buttonBox_accepted()
|
||||||
tabSelection->setCurrentRow(TAB_SPEED);
|
tabSelection->setCurrentRow(TAB_SPEED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!webUIAuthenticationOk()) {
|
||||||
|
tabSelection->setCurrentRow(TAB_WEBUI);
|
||||||
|
return;
|
||||||
|
}
|
||||||
applyButton->setEnabled(false);
|
applyButton->setEnabled(false);
|
||||||
this->hide();
|
this->hide();
|
||||||
saveOptions();
|
saveOptions();
|
||||||
|
@ -1039,6 +1042,10 @@ void options_imp::applySettings(QAbstractButton* button)
|
||||||
tabSelection->setCurrentRow(TAB_SPEED);
|
tabSelection->setCurrentRow(TAB_SPEED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!webUIAuthenticationOk()) {
|
||||||
|
tabSelection->setCurrentRow(TAB_WEBUI);
|
||||||
|
return;
|
||||||
|
}
|
||||||
saveOptions();
|
saveOptions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1526,15 +1533,22 @@ void options_imp::setSslCertificate(const QByteArray &cert, bool interactive)
|
||||||
|
|
||||||
bool options_imp::schedTimesOk()
|
bool options_imp::schedTimesOk()
|
||||||
{
|
{
|
||||||
QString msg;
|
if (schedule_from->time() == schedule_to->time()) {
|
||||||
|
QMessageBox::warning(this, tr("Time Error"), tr("The start time and the end time can't be the same."));
|
||||||
if (schedule_from->time() == schedule_to->time())
|
return false;
|
||||||
msg = tr("The start time and the end time can't be the same.");
|
}
|
||||||
|
return true;
|
||||||
if (!msg.isEmpty()) {
|
}
|
||||||
QMessageBox::critical(this, tr("Time Error"), msg);
|
|
||||||
|
bool options_imp::webUIAuthenticationOk()
|
||||||
|
{
|
||||||
|
if (webUiUsername().length() < 3) {
|
||||||
|
QMessageBox::warning(this, tr("Length Error"), tr("The Web UI username must be at least 3 characters long."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (webUiPassword().length() < 6) {
|
||||||
|
QMessageBox::warning(this, tr("Length Error"), tr("The Web UI password must be at least 6 characters long."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,7 @@ private:
|
||||||
void setSslKey(const QByteArray &key, bool interactive = true);
|
void setSslKey(const QByteArray &key, bool interactive = true);
|
||||||
void setSslCertificate(const QByteArray &cert, bool interactive = true);
|
void setSslCertificate(const QByteArray &cert, bool interactive = true);
|
||||||
bool schedTimesOk();
|
bool schedTimesOk();
|
||||||
|
bool webUIAuthenticationOk();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QButtonGroup choiceLanguage;
|
QButtonGroup choiceLanguage;
|
||||||
|
|
|
@ -58,8 +58,6 @@ static const char *__TRANSLATIONS__[] = {
|
||||||
QT_TRANSLATE_NOOP("HttpServer", "Language"),
|
QT_TRANSLATE_NOOP("HttpServer", "Language"),
|
||||||
QT_TRANSLATE_NOOP("HttpServer", "The port used for incoming connections must be between 1 and 65535."),
|
QT_TRANSLATE_NOOP("HttpServer", "The port used for incoming connections must be between 1 and 65535."),
|
||||||
QT_TRANSLATE_NOOP("HttpServer", "The port used for the Web UI must be between 1 and 65535."),
|
QT_TRANSLATE_NOOP("HttpServer", "The port used for the Web UI must be between 1 and 65535."),
|
||||||
QT_TRANSLATE_NOOP("HttpServer", "The Web UI username must be at least 3 characters long."),
|
|
||||||
QT_TRANSLATE_NOOP("HttpServer", "The Web UI password must be at least 3 characters long."),
|
|
||||||
QT_TRANSLATE_NOOP("HttpServer", "Save"),
|
QT_TRANSLATE_NOOP("HttpServer", "Save"),
|
||||||
QT_TRANSLATE_NOOP("HttpServer", "qBittorrent client is not reachable"),
|
QT_TRANSLATE_NOOP("HttpServer", "qBittorrent client is not reachable"),
|
||||||
QT_TRANSLATE_NOOP("HttpServer", "HTTP Server"),
|
QT_TRANSLATE_NOOP("HttpServer", "HTTP Server"),
|
||||||
|
|
|
@ -1239,14 +1239,13 @@ applyPreferences = function() {
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
var web_ui_username = $('webui_username_text').getProperty('value');
|
var web_ui_username = $('webui_username_text').getProperty('value');
|
||||||
var web_ui_password = $('webui_password_text').getProperty('value');
|
|
||||||
// Add some username/password length checking
|
|
||||||
if(web_ui_username.length < 3) {
|
if(web_ui_username.length < 3) {
|
||||||
alert("QBT_TR(The Web UI username must be at least 3 characters long.)QBT_TR");
|
alert("QBT_TR(The Web UI username must be at least 3 characters long.)QBT_TR");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(web_ui_password.length < 3) {
|
var web_ui_password = $('webui_password_text').getProperty('value');
|
||||||
alert("QBT_TR(The Web UI password must be at least 3 characters long.)QBT_TR");
|
if(web_ui_password.length < 6) {
|
||||||
|
alert("QBT_TR(The Web UI password must be at least 6 characters long.)QBT_TR");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
settings.set('web_ui_username', web_ui_username);
|
settings.set('web_ui_username', web_ui_username);
|
||||||
|
|
Loading…
Reference in a new issue