]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
First stage of username/password stuff for hyperion.
authorChris Porter <redacted>
Sun, 21 Jun 2009 23:46:41 +0000 (00:46 +0100)
committerChris Porter <redacted>
Sun, 21 Jun 2009 23:46:41 +0000 (00:46 +0100)
js/auth.js
js/irc/baseircclient.js
js/irc/ircconnection.js
js/ui/panes/connect.js
qwebirc/engines/ajaxengine.py
qwebirc/ircclient.py

index 809f5f0d87ac0da9bec0215c0d2aab8431fb93b8..8244b7e01e15b0441120b4d66b8c1eb0c6ae4fa3 100644 (file)
@@ -3,6 +3,15 @@ qwebirc.auth.loggedin = function() {
   
   return user;
 }
+
 qwebirc.auth.enabled = function() {
+  return true;
+}
+
+qwebirc.auth.quakeNetAuth = function() {
+  return false;
+}
+
+qwebirc.auth.passAuth = function() {
   return false;
 }
index 0c1e314f69f67a832588be326a9741e151a514c4..ea8ff6adf453d412132504aea7bd08f345211e24 100644 (file)
@@ -23,7 +23,11 @@ qwebirc.irc.BaseIRCClient = new Class({
     this.channels = {}
     this.nextctcp = 0;    
 
-    this.connection = new qwebirc.irc.IRCConnection({initialNickname: this.nickname, onRecv: this.dispatch.bind(this)});
+    this.connection = new qwebirc.irc.IRCConnection({
+      initialNickname: this.nickname,
+      onRecv: this.dispatch.bind(this),
+      serverPassword: this.options.serverPassword
+    });
   
     this.send = this.connection.send.bind(this.connection);
     this.connect = this.connection.connect.bind(this.connection);
index e85fd58fb9018baba3f7ea5ad276ddaa60e536e0..e006c986a60979ca7612d2029e359a974b2f5375 100644 (file)
@@ -9,7 +9,8 @@ qwebirc.irc.IRCConnection = new Class({
     floodMax: 10,
     floodReset: 5000,
     errorAlert: true,
-    maxRetries: 5
+    maxRetries: 5,
+    serverPassword: null
   },
   initialize: function(options) {
     this.setOptions(options);
@@ -213,7 +214,12 @@ qwebirc.irc.IRCConnection = new Class({
       
       this.recv();    
     }.bind(this));
-    r.send("nick=" + encodeURIComponent(this.initialNickname));
+    
+    var postdata = "nick=" + encodeURIComponent(this.initialNickname);
+    if($defined(this.options.serverPassword))
+      postdata+="&password=" + encodeURIComponent(this.options.serverPassword);
+      
+    r.send(postdata);
   },
   __cancelRequests: function() {
     if($defined(this.__lastActiveRequest)) {
index e1ac3ccc21f9fdcdfe994e5142532552315a87e1..cd1c61cb3036b73284b08ee61e5bc1807e18a1a3 100644 (file)
@@ -128,7 +128,7 @@ qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initial
   var tbody = new Element("tbody");
   boxtable.appendChild(tbody); /* stupid IE */
 
-  function createRow(label, e2) {
+  function createRow(label, e2, style) {
     var r = new Element("tr");
     tbody.appendChild(r);
 
@@ -139,7 +139,14 @@ qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initial
 
     var d2 = new Element("td");
     r.appendChild(d2);
-    d2.appendChild(e2);
+    
+    if($defined(e2))
+      d2.appendChild(e2);
+    if($defined(style)) {
+      r.setStyles(style);
+      return [r, d2];
+    }
+    
     return d2;
   }
 
@@ -148,10 +155,24 @@ qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initial
   var chan = new Element("input");
   createRow("Channels:", chan);
 
+  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);
+    
+    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];
+
+    checkBox.addEvent("click", function(e) { qwebirc.ui.authShowHide(checkBox, authRow, usernameBox, usernameRow, passwordRow) });
+  }
+  
   var connbutton = new Element("input", {"type": "submit"});
   connbutton.set("value", "Connect");
-  var r = createRow(undefined, connbutton)
-  if(qwebirc.auth.enabled() && !qwebirc.auth.loggedin()) {
+  var r = createRow(undefined, connbutton);
+  
+  if(qwebirc.auth.enabled() && qwebirc.auth.quakeNetAuth() && !qwebirc.auth.loggedin()) {
     var auth = new Element("input", {"type": "submit", "value": "Log in"});
     r.appendChild(auth);
     auth.addEvent("click", qwebirc.ui.AuthLogin);
@@ -172,7 +193,11 @@ qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initial
 
     parentElement.removeChild(outerbox);
     
-    callback({"nickname": nickname, "autojoin": chans});
+    var data = {"nickname": nickname, "autojoin": chans};
+    if($defined(usernameBox) && usernameBox.value && passwordBox.value)
+      data["serverPassword"] = usernameBox.value + " " + passwordBox.value;
+      
+    callback(data);
   }.bind(this));
 
   nick.set("value", initialNickname);
@@ -180,3 +205,15 @@ qwebirc.ui.LoginBox = function(parentElement, callback, initialNickname, initial
 
   nick.focus();
 }
+
+qwebirc.ui.authShowHide = function(checkbox, authRow, usernameBox, usernameRow, passwordRow) {
+  var visible = checkbox.checked;
+  var display = visible?null:"none";
+  usernameRow.setStyle("display", display);
+  passwordRow.setStyle("display", display);
+  
+  if(visible) {
+//    authRow.parentNode.setStyle("display", "none");
+    usernameBox.focus();
+  }
+}
index 0212e5a7f736d0212f6f23bda5add2cbd7f87530..6d272d2ea6af9bafb37c47022969794697c08506 100644 (file)
@@ -190,6 +190,10 @@ class AJAXEngine(resource.Resource):
       raise AJAXException, "Nickname not supplied."
     nick = ircclient.irc_decode(nick[0])
 
+    password = request.args.get("pass")
+    if password is not None:
+      password = ircclient.irc_decode(password[0])
+      
     for i in xrange(10):
       id = get_session_id()
       if not Sessions.get(id):
@@ -214,7 +218,11 @@ class AJAXEngine(resource.Resource):
     self.__connect_hit()
 
     def proceed(hostname):
-      client = ircclient.createIRC(session, nick=nick, ident=ident, ip=ip, realname=realname, perform=perform, hostname=hostname)
+      kwargs = dict(nick=nick, ident=ident, ip=ip, realname=realname, perform=perform, hostname=hostname)
+      if password is not None:
+        kwargs["password"] = password
+        
+      client = ircclient.createIRC(session, **kwargs)
       session.client = client
 
     if config.WEBIRC_MODE != "hmac":
index 8b9b3e59ef0731e586ebd93ee514ac7dccb28eb1..0e0291151b834f3652933dfcc8dbd6ab525711bd 100644 (file)
@@ -71,7 +71,7 @@ class QWebIRCClient(basic.LineReceiver):
     
     self.lastError = None
     f = self.factory.ircinit
-    nick, ident, ip, realname, hostname = f["nick"], f["ident"], f["ip"], f["realname"], f["hostname"]
+    nick, ident, ip, realname, hostname, pass_ = f["nick"], f["ident"], f["ip"], f["realname"], f["hostname"], f.get("pass")
     self.__nickname = nick
     self.__perform = f.get("perform")
 
@@ -92,6 +92,8 @@ class QWebIRCClient(basic.LineReceiver):
 
       self.write("USER %s bleh bleh :%s - %s" % (ident, dispip, realname))
 
+    if pass_ is not None:
+      self.write("PASS :%s" % pass_)
     self.write("NICK %s" % nick)
     
     self.factory.client = self