summaryrefslogtreecommitdiff
path: root/src/srp_session.js
diff options
context:
space:
mode:
authorkaeff <hi@kaeff.net>2015-09-09 01:13:34 +0200
committerkaeff <hi@kaeff.net>2015-09-17 16:01:04 +0200
commit2d24b1fe1918ad96df4469f8902c3ddcb9bda5f9 (patch)
tree12c065893ae4e3cd31b980088aafc41d48a54532 /src/srp_session.js
parent8f33d32d40b1e21ae7fb9a92c78a275422af4217 (diff)
Allow extra signup params from account
For the feature/invite-codes in leap_web, we need to be able to pass an extra parameter (the invite code) from the signup form to the server. This approach allows the consumer of SRP to specify a custom implementation of Account that returns arbitrary `loginParams`, and Session will pass them on so that they become part of the XHR. - Split session.signup into signup and update to restrict extra params to signup only
Diffstat (limited to 'src/srp_session.js')
-rw-r--r--src/srp_session.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/srp_session.js b/src/srp_session.js
index bdff9c4..88f19d5 100644
--- a/src/srp_session.js
+++ b/src/srp_session.js
@@ -22,7 +22,7 @@ srp.Session = function(account, calculate) {
return A;
};
- this.signup = function() {
+ this.update = function() {
var salt = calculate.randomSalt();
var x = calculate.X(account.login(), account.password(), salt);
return {
@@ -30,6 +30,19 @@ srp.Session = function(account, calculate) {
password_salt: salt,
password_verifier: calculate.V(x)
};
+ }
+
+ this.signup = function() {
+ var loginParams = this.update();
+
+ if (account.loginParams) {
+ var extraParams = account.loginParams();
+ for (var attr in extraParams) {
+ loginParams[attr] = extraParams[attr];
+ }
+ }
+
+ return loginParams;
};
this.handshake = function() {