From 2d24b1fe1918ad96df4469f8902c3ddcb9bda5f9 Mon Sep 17 00:00:00 2001 From: kaeff Date: Wed, 9 Sep 2015 01:13:34 +0200 Subject: 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 --- spec/session_spec.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'spec') diff --git a/spec/session_spec.js b/spec/session_spec.js index 2f58d25..b37d7b1 100644 --- a/spec/session_spec.js +++ b/spec/session_spec.js @@ -72,4 +72,37 @@ describe("Session", function() { session = new srp.Session(account); expect(session.login()).toBe(compare.username); }); + + it('calculates secure user parameters for signup', function() { + var compare = short_b; + account = new srp.Account(compare.username, compare.password); + session = new srp.Session(account); + + var signupParams = session.signup(); + + expect(Object.keys(signupParams)).toEqual(['login', 'password_salt', 'password_verifier']); + }); + + it('calculates secure user parameters for update', function() { + var compare = short_b; + account = new srp.Account(compare.username, compare.password); + session = new srp.Session(account); + + var signupParams = session.update(); + + expect(Object.keys(signupParams)).toEqual(['login', 'password_salt', 'password_verifier']); + }); + + it("grabs extra signup parameters from account", function() { + account = jasmine.createSpyObj('account', ['login', 'password']); + account.loginParams = function() { + return { + "extraParam": "foobar" + } + } + session = new srp.Session(account); + + expect(session.signup().extraParam).toBe("foobar"); + }); + }); -- cgit v1.2.3