From: Chris Porter Date: Mon, 22 Jun 2009 02:17:30 +0000 (+0100) Subject: Fix several login bugs, add bouncer auth mode. X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/commitdiff_plain/6ce70043d7bcfee7b3275ec188cc2217a4902387 Fix several login bugs, add bouncer auth mode. --- diff --git a/js/auth.js b/js/auth.js index 8244b7e..d0e1be4 100644 --- a/js/auth.js +++ b/js/auth.js @@ -5,7 +5,7 @@ qwebirc.auth.loggedin = function() { } qwebirc.auth.enabled = function() { - return true; + return false; } qwebirc.auth.quakeNetAuth = function() { @@ -13,5 +13,9 @@ qwebirc.auth.quakeNetAuth = function() { } qwebirc.auth.passAuth = function() { + return true; +} + +qwebirc.auth.bouncerAuth = function() { return false; } diff --git a/js/irc/ircclient.js b/js/irc/ircclient.js index a4d193e..b8cee6f 100644 --- a/js/irc/ircclient.js +++ b/js/irc/ircclient.js @@ -24,6 +24,7 @@ qwebirc.irc.IRCClient = new Class({ this.activeTimers = {}; this.loginRegex = new RegExp(this.ui.options.loginRegex); + this.tracker = new qwebirc.irc.IRCTracker(this); }, newLine: function(window, type, data) { if(!data) diff --git a/js/ui/panes/connect.js b/js/ui/panes/connect.js index cd1c61c..9161bfe 100644 --- a/js/ui/panes/connect.js +++ b/js/ui/panes/connect.js @@ -61,7 +61,7 @@ qwebirc.ui.ConfirmBox = function(parentElement, callback, initialNickname, initi text.appendChild(document.createTextNode(" click 'Connect'.")); text.appendChild(new Element("br")); - if(qwebirc.auth.enabled() && !qwebirc.auth.loggedin()) + if(qwebirc.auth.enabled() && qwebirc.auth.quakeNetAuth() && !qwebirc.auth.loggedin()) text.appendChild(document.createTextNode("If you'd like to connect using your Q auth click 'Log in'.")); var tr = new Element("tr"); @@ -79,7 +79,7 @@ qwebirc.ui.ConfirmBox = function(parentElement, callback, initialNickname, initi callback({"nickname": initialNickname, "autojoin": initialChannels}); }); - if(qwebirc.auth.enabled() && !qwebirc.auth.loggedin()) { + if(qwebirc.auth.enabled() && qwebirc.auth.quakeNetAuth() && !qwebirc.auth.loggedin()) { var auth = new Element("input", {"type": "submit", "value": "Log in"}); td.appendChild(auth); auth.addEvent("click", qwebirc.ui.AuthLogin); @@ -152,20 +152,30 @@ qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initial var nick = new Element("input"); createRow("Nickname:", nick); + + var chanStyle = null; + if(qwebirc.auth.enabled() && qwebirc.auth.bouncerAuth()) + chanStyle = {display: "none"}; + var chan = new Element("input"); - createRow("Channels:", chan); + createRow("Channels:", chan, chanStyle); - if(qwebirc.auth.enabled() && qwebirc.auth.passAuth()) { - var authRow = createRow("Auth to services:"); - var checkBox = qwebirc.util.createInput("checkbox", authRow, "connect_auth_to_services", false); + if(qwebirc.auth.enabled()) { + if(qwebirc.auth.passAuth()) { + var authRow = createRow("Auth to services:"); + var authCheckBox = qwebirc.util.createInput("checkbox", authRow, "connect_auth_to_services", false); - var usernameBox = new Element("input"); - var usernameRow = createRow("Username:", usernameBox, {display: "none"})[0]; + var usernameBox = new Element("input"); + var usernameRow = createRow("Username:", usernameBox, {display: "none"})[0]; - var passwordBox = new Element("input"); - var passwordRow = createRow("Password:", passwordBox, {display: "none"})[0]; + var passwordRow = createRow("Password:", null, {display: "none"}); + var passwordBox = qwebirc.util.createInput("password", passwordRow[1], "connect_auth_password"); - checkBox.addEvent("click", function(e) { qwebirc.ui.authShowHide(checkBox, authRow, usernameBox, usernameRow, passwordRow) }); + authCheckBox.addEvent("click", function(e) { qwebirc.ui.authShowHide(authCheckBox, authRow, usernameBox, usernameRow, passwordRow[0]) }); + } else if(qwebirc.auth.bouncerAuth()) { + var passwordRow = createRow("Password:"); + var passwordBox = qwebirc.util.createInput("password", passwordRow, "connect_auth_password"); + } } var connbutton = new Element("input", {"type": "submit"}); @@ -191,15 +201,34 @@ qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initial return; } - parentElement.removeChild(outerbox); - var data = {"nickname": nickname, "autojoin": chans}; - if($defined(usernameBox) && usernameBox.value && passwordBox.value) - data["serverPassword"] = usernameBox.value + " " + passwordBox.value; + if(qwebirc.auth.passAuth() && authCheckBox.checked) { + if(!usernameBox.value || !passwordBox.value) { + alert("You must supply your username and password in auth mode."); + if(!usernameBox.value) { + usernameBox.focus(); + } else { + passwordBox.focus(); + } + return; + } + + data["serverPassword"] = usernameBox.value + " " + passwordBox.value; + } else if(qwebirc.auth.bouncerAuth()) { + if(!passwordBox.value) { + alert("You must supply a password."); + passwordBox.focus(); + return; + } + data["serverPassword"] = passwordBox.value; + } + + parentElement.removeChild(outerbox); + callback(data); }.bind(this)); - + nick.set("value", initialNickname); chan.set("value", initialChannels); diff --git a/qwebirc/engines/ajaxengine.py b/qwebirc/engines/ajaxengine.py index 3750175..a7acb46 100644 --- a/qwebirc/engines/ajaxengine.py +++ b/qwebirc/engines/ajaxengine.py @@ -190,7 +190,7 @@ class AJAXEngine(resource.Resource): raise AJAXException, "Nickname not supplied." nick = ircclient.irc_decode(nick[0]) - password = request.args.get("pass") + password = request.args.get("password") if password is not None: password = ircclient.irc_decode(password[0]) diff --git a/qwebirc/ircclient.py b/qwebirc/ircclient.py index 7f3cecd..f343986 100644 --- a/qwebirc/ircclient.py +++ b/qwebirc/ircclient.py @@ -71,7 +71,7 @@ class QWebIRCClient(basic.LineReceiver): self.lastError = None f = self.factory.ircinit - nick, ident, ip, realname, hostname, pass_ = f["nick"], f["ident"], f["ip"], f["realname"], f["hostname"], f.get("pass") + nick, ident, ip, realname, hostname, pass_ = f["nick"], f["ident"], f["ip"], f["realname"], f["hostname"], f.get("password") self.__nickname = nick self.__perform = f.get("perform")