From 50de80c5e817476ac95a096c718a66f5555fcd05 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 20 Jul 2012 10:56:36 +0200 Subject: INCOMPATIBLE: major restructuring of the repository * removed Django code - we're keeping the tests - so I hope the two can still be used together * removed js packer - everyone has their own packaging strategy these days * cleaned up the repository - we only have js so javascript directory does not make much sense --- src/srp_register.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/srp_register.js (limited to 'src/srp_register.js') diff --git a/src/srp_register.js b/src/srp_register.js new file mode 100644 index 0000000..3966d79 --- /dev/null +++ b/src/srp_register.js @@ -0,0 +1,46 @@ +function SRP_REGISTER() +{ + var that; + + // 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); + }; + + // Receive the salt for registration + SRP.prototype.register_receive_salt = function(response) + { + if(response.salt) + { + var s = response.salt; + var x = that.calcX(s); + var v = that.getg().modPow(x, that.getN()); + that.register_send_verifier(v.toString(16)); + } + else if(response.error) + { + that.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(); + } + }; +}; +SRP_REGISTER(); -- cgit v1.2.3