From 4e06a9629a3c24672c05dfbbe84703c30b6828aa Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 13 Sep 2022 13:00:11 +0800 Subject: [PATCH] WebUI: alert when HTTPS settings are incomplete Closes #17696. PR #17701. --- src/webui/www/private/views/preferences.html | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 7328dc972..71c6f1f91 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -2382,9 +2382,23 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD settings.set('web_ui_address', web_ui_address); settings.set('web_ui_port', web_ui_port); settings.set('web_ui_upnp', $('webui_upnp_checkbox').getProperty('checked')); - settings.set('use_https', $('use_https_checkbox').getProperty('checked')); - settings.set('web_ui_https_cert_path', $('ssl_cert_text').getProperty('value')); - settings.set('web_ui_https_key_path', $('ssl_key_text').getProperty('value')); + + const useHTTPS = $('use_https_checkbox').getProperty('checked'); + settings.set('use_https', useHTTPS); + + const httpsCertificate = $('ssl_cert_text').getProperty('value'); + settings.set('web_ui_https_cert_path', httpsCertificate); + if (useHTTPS && (httpsCertificate.length === 0)) { + alert("QBT_TR(HTTPS certificate should not be empty)QBT_TR[CONTEXT=OptionsDialog]"); + return; + } + + const httpsKey = $('ssl_key_text').getProperty('value'); + settings.set('web_ui_https_key_path', httpsKey); + if (useHTTPS && (httpsKey.length === 0)) { + alert("QBT_TR(HTTPS key should not be empty)QBT_TR[CONTEXT=OptionsDialog]"); + return; + } // Authentication const web_ui_username = $('webui_username_text').getProperty('value');