diff --git a/lib/client.js b/lib/client.js index 856ecb3ad..33fd10783 100644 --- a/lib/client.js +++ b/lib/client.js @@ -802,15 +802,6 @@ MatrixClient.prototype.publicRooms = function(callback) { return this._http.request(callback, "GET", "/publicRooms"); }; -/** - * @param {module:client.callback} callback Optional. - * @return {module:client.Promise} Resolves: TODO - * @return {module:http-api.MatrixError} Rejects: with an error response. - */ -MatrixClient.prototype.registerFlows = function(callback) { - return this._http.request(callback, "GET", "/register"); -}; - /** * @param {module:client.callback} callback Optional. * @return {module:client.Promise} Resolves: TODO @@ -932,16 +923,24 @@ MatrixClient.prototype.login = function(loginType, data, callback) { }; /** - * @param {string} loginType - * @param {Object} data + * @param {string} username + * @param {string} password + * @param {string} session_id + * @param {Object} auth * @param {module:client.callback} callback Optional. * @return {module:client.Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. */ -MatrixClient.prototype.register = function(loginType, data, callback) { - data.type = loginType; - return this._http.authedRequest( - callback, "POST", "/register", undefined, data +MatrixClient.prototype.register = function(username, password, session_id, auth, callback) { + if (auth === undefined) auth = {}; + auth.session = session_id; + return this._http.requestWithPrefix( + callback, "POST", "/register", undefined, + { + username: username, + password: password, + auth: auth + }, httpApi.PREFIX_V2_ALPHA ); }; diff --git a/lib/http-api.js b/lib/http-api.js index 5c8b7b0d5..3aa553157 100644 --- a/lib/http-api.js +++ b/lib/http-api.js @@ -352,6 +352,7 @@ var requestCallback = function(defer, userDefinedCallback, onlyData) { return function(err, response, body) { if (!err && response.statusCode >= 400) { err = new module.exports.MatrixError(body); + err.httpStatus = response.statusCode; } if (err) {