From f2930d4f6f0310a4e764e58cd5ef3dc674d11e14 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 2 Jul 2012 12:25:38 +0200 Subject: check for ready state and status before callback --- javascript/srp_register.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'javascript/srp_register.js') diff --git a/javascript/srp_register.js b/javascript/srp_register.js index 670e59d..ffadf81 100644 --- a/javascript/srp_register.js +++ b/javascript/srp_register.js @@ -15,18 +15,16 @@ function SRP_REGISTER() SRP.prototype.register_receive_salt = function() { var xhr = that.getxhr(); - if(xhr.readyState == 4 && xhr.status == 200) { - if(xhr.responseXML.getElementsByTagName("salt").length > 0) - { - var s = that.innerxml(xhr.responseXML.getElementsByTagName("salt")[0]); - var x = that.calcX(s); - var v = that.getg().modPow(x, that.getN()); - that.register_send_verifier(v.toString(16)); - } - else if(xhr.responseXML.getElementsByTagName("error").length > 0) - { - that.error_message(that.innerxml(xhr.responseXML.getElementsByTagName("error")[0])); - } + if(xhr.responseXML.getElementsByTagName("salt").length > 0) + { + var s = that.innerxml(xhr.responseXML.getElementsByTagName("salt")[0]); + var x = that.calcX(s); + var v = that.getg().modPow(x, that.getN()); + that.register_send_verifier(v.toString(16)); + } + else if(xhr.responseXML.getElementsByTagName("error").length > 0) + { + that.error_message(that.innerxml(xhr.responseXML.getElementsByTagName("error")[0])); } }; // Send the verifier to the server @@ -41,11 +39,9 @@ function SRP_REGISTER() SRP.prototype.register_user = function() { var xhr = that.getxhr(); - if(xhr.readyState == 4 && xhr.status == 200) { - if(xhr.responseXML.getElementsByTagName("ok").length > 0) - { - that.identify(); - } + if(xhr.responseXML.getElementsByTagName("ok").length > 0) + { + that.identify(); } }; }; -- cgit v1.2.3