From 94d1938e2e5d0ee5e8e7b9a8ed44a067677e0133 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 3 Aug 2012 20:37:11 +0200 Subject: moved all xhr related stuff to a seperate class We can replace this if we want to use jquery ajax or similar. Also this has all the urls so it's super easy to overwrite --- lib/srp_register.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'lib/srp_register.js') diff --git a/lib/srp_register.js b/lib/srp_register.js index 1666476..8365fed 100644 --- a/lib/srp_register.js +++ b/lib/srp_register.js @@ -5,10 +5,8 @@ function SRP_REGISTER() // Initiate the registration process SRP.prototype.register = function() { - that = this; - var handshake_url = this.geturl() + this.paths("register/salt/"); - var params = "I="+this.getI(); - this.ajaxRequest(handshake_url, params, this.register_receive_salt); + session = this; + this.remote.register(this.getI(), session.register_receive_salt); }; // Receive the salt for registration @@ -17,28 +15,20 @@ function SRP_REGISTER() if(response.salt) { var s = response.salt; - var v = that.calcV(s); - that.register_send_verifier(v.toString(16)); + var v = session.calcV(s); + session.remote.register_send_verifier(v.toString(16), session.registered_user); } else if(response.error) { - that.error_message(response.error); + session.error_message(response.error); } }; - // Send the verifier to the server - SRP.prototype.register_send_verifier = function(v) - { - var params = "v="+v; - var auth_url = that.geturl() + that.paths("register/user/"); - that.ajaxRequest(auth_url, params, that.registered_user); - }; - // The user has been registered successfully, now login SRP.prototype.registered_user = function(response) { if(response.ok) { - that.identify(); + session.identify(); } }; }; -- cgit v1.2.3