From d5e30a95e09bab18a55f9aad1572b6ae3e16e482 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 21 Aug 2012 17:14:06 +0200 Subject: moved on with refactoring * srp_register now is part of srp.js * moved server specific stuff into plainXHR (such as fetching the seed from the server) * fixed tests --- lib/plainXHR.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'lib/plainXHR.js') diff --git a/lib/plainXHR.js b/lib/plainXHR.js index 95ceeac..d07416b 100644 --- a/lib/plainXHR.js +++ b/lib/plainXHR.js @@ -1,3 +1,12 @@ +// +// SRP JS - Plain XHR module +// +// This is deprecated - unless you are using srp-js with the original drupal +// server side I recommend you use a different API such as restful.js +// +// This code has been largely refactored, tests are still passing but I did +// not test it with the server itself. + SRP.prototype.Remote = function() { // Perform ajax requests at the specified path, with the specified parameters @@ -78,10 +87,23 @@ SRP.prototype.Remote = function() { } return response; }; - + + // Drupal version fetches the salt from the server. No idea why but this + // should still do it. this.register = function(session, callback) { - ajaxRequest("register/salt/", "I="+session.getI(), callback); + var that = this; + ajaxRequest("register/salt/", "I="+session.getI(), receive_salt); + + function receive_salt(response) + { + if(response.salt) + { + var s = response.salt; + var v = session.getV(s); + that.sendVerifier(session, callback); + } + }; } this.sendVerifier = function(session, callback) { -- cgit v1.2.3