diff --git a/deluge/ui/web/js/deluge-connections.js b/deluge/ui/web/js/deluge-connections.js index 830b943ae..0d7f78d4b 100644 --- a/deluge/ui/web/js/deluge-connections.js +++ b/deluge/ui/web/js/deluge-connections.js @@ -52,14 +52,14 @@ Deluge.Connections = { var host = form.items.get('host').getValue(); var port = form.items.get('port').getValue(); var username = form.items.get('username').getValue(); - var password = form.items.get('password').getValue(); + var password = form.items.get('_password').getValue(); Deluge.Client.web.add_host(host, port, username, password, { onSuccess: function(result) { - if (!result) { + if (!result[0]) { Ext.MessageBox.show({ title: _('Error'), - msg: "Unable to add host", + msg: "Unable to add host: " + result[1], buttons: Ext.MessageBox.OK, modal: false, icon: Ext.MessageBox.ERROR, @@ -79,7 +79,7 @@ Deluge.Connections = { form.items.get('host').reset(); form.items.get('port').reset(); form.items.get('username').reset(); - form.items.get('password').reset(); + form.items.get('_password').reset(); }, onClose: function(e) { diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 0f296f137..0f535d494 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -480,14 +480,20 @@ class WebApi(JSONComponent): # if thats the case for entry in self.host_list["hosts"]: if (entry[0], entry[1], entry[2]) == (host, port, username): - d.callback(False) + d.callback((False, "Host already in the list")) + + try: + port = int(port) + except: + d.callback((False, "Port is invalid")) + return d # Host isn't in the list, so lets add it connection_id = hashlib.sha1(str(time.time())).hexdigest() self.host_list["hosts"].append([connection_id, host, port, username, password]) self.host_list.save() - d.callback(True) + d.callback((True,)) return d @export