diff options
author | Azul <azul@leap.se> | 2012-08-03 20:37:11 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-08-03 20:37:11 +0200 |
commit | 94d1938e2e5d0ee5e8e7b9a8ed44a067677e0133 (patch) | |
tree | ffdae863dda3b197d6e165bffa5a782e9e1ab338 /lib/srp_register.js | |
parent | 0da31f678580649415cb0487c830f21d7e163253 (diff) |
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
Diffstat (limited to 'lib/srp_register.js')
-rw-r--r-- | lib/srp_register.js | 22 |
1 files changed, 6 insertions, 16 deletions
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(); } }; }; |