# HG changeset patch # User Giulio Moro # Date 1461786240 -3600 # Node ID 18d390c66b476db8222c710bcb773ac6b855dd08 # Parent a73495c6d604e129d43013581a7a14e90ff75733 Addresses issue #35, though I am not sure if there are any side-effects diff -r a73495c6d604 -r 18d390c66b47 js/core.js --- a/js/core.js Wed Apr 27 21:50:33 2016 +0100 +++ b/js/core.js Wed Apr 27 20:44:00 2016 +0100 @@ -2822,13 +2822,18 @@ handleEvent: function() { var parse = new DOMParser(); var xml = parse.parseFromString(this.request.response,"text/xml"); - if (xml.getAllElementsByTagName("state")[0].textContent == "OK") { - this.key = xml.getAllElementsByTagName("key")[0].textContent; - this.parent.root.setAttribute("key",this.key); - this.parent.root.setAttribute("state","empty"); - } else { - this.generateKey(); - } + var shouldGenerateKey = true; + if(xml.getAllElementsByTagName("state").length > 0){ + if (xml.getAllElementsByTagName("state")[0].textContent == "OK") { + this.key = xml.getAllElementsByTagName("key")[0].textContent; + this.parent.root.setAttribute("key",this.key); + this.parent.root.setAttribute("state","empty"); + shouldGenerateKey = false; + } + } + if(shouldGenerateKey === true){ + this.generateKey(); + } }, generateKey: function() { var temp_key = randomString(32);