From 8c1cc0f4903b1b6eabffe6681744ea02a870af7f Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 19 Oct 2012 17:49:53 +0200 Subject: added success and error callbacks to register --- src/srp.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/srp.js b/src/srp.js index c986443..7060598 100644 --- a/src/srp.js +++ b/src/srp.js @@ -11,8 +11,7 @@ function SRP(remote, session) // Start the login process by identifying the user this.identify = function(success, error) { - srp.success = success; - srp.error = error; + store_callbacks(success, error); remote.handshake(session, receive_salts); // Receive login salts from the server, start calculations @@ -45,8 +44,9 @@ function SRP(remote, session) }; // Initiate the registration process - this.register = function() + this.register = function(success, error) { + store_callbacks(success, error); remote.register(session, srp.registered_user); }; @@ -71,5 +71,14 @@ function SRP(remote, session) { alert("Login successful."); }; + + function store_callbacks(success, error) { + if (typeof success == "function") { + srp.success = success; + } + if (typeof error == "function") { + srp.error = error; + } + } }; -- cgit v1.2.3