summaryrefslogtreecommitdiff
path: root/lib/srp_register.js
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-07-20 11:18:47 +0200
committerAzul <azul@leap.se>2012-07-20 11:18:47 +0200
commitfcb9e65af31569db33c198217df816971f2f20cd (patch)
tree273f604e9f81280aa0686db74cb4a7dfa65e5c86 /lib/srp_register.js
parent621c73c593b38a514d573c9128df62d3a17b5ed9 (diff)
moved src to lib and use relative path in require_tree
Diffstat (limited to 'lib/srp_register.js')
-rw-r--r--lib/srp_register.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/srp_register.js b/lib/srp_register.js
new file mode 100644
index 0000000..3966d79
--- /dev/null
+++ b/lib/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();