diff --git a/lib/client.js b/lib/client.js index 8f36af911..3334564a7 100644 --- a/lib/client.js +++ b/lib/client.js @@ -935,14 +935,17 @@ MatrixClient.prototype.login = function(loginType, data, callback) { MatrixClient.prototype.register = function(username, password, session_id, auth, callback) { if (auth === undefined) { auth = {}; } - auth.session = session_id; + if (session_id) auth.session = session_id; + + var params = { + auth: auth + }; + if (username !== undefined) params.username = username; + if (password !== undefined ) params.password = password; + return this._http.requestWithPrefix( callback, "POST", "/register", undefined, - { - username: username, - password: password, - auth: auth - }, httpApi.PREFIX_V2_ALPHA + params, httpApi.PREFIX_V2_ALPHA ); }; @@ -1389,16 +1392,18 @@ function _PojoToMatrixEventMapper(plainOldJsObject) { * @param {string} email * @param {string} client_secret * @param {string} send_attempt + * @param {string} next_link Optional * @param {module:client.callback} callback Optional. * @return {module:client.Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. */ MatrixClient.prototype.requestEmailToken = function(email, client_secret, - send_attempt, callback) { + send_attempt, next_link, callback) { var params = { client_secret: client_secret, email: email, - send_attempt: send_attempt + send_attempt: send_attempt, + next_link: next_link }; return this._http.idServerRequest( callback, "POST", "/validate/email/requestToken",