1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

Support V2 registration

This commit is contained in:
David Baker
2015-07-13 19:15:10 +01:00
parent 9f930f7d0d
commit 864fdcb925
2 changed files with 15 additions and 15 deletions

View File

@@ -802,15 +802,6 @@ MatrixClient.prototype.publicRooms = function(callback) {
return this._http.request(callback, "GET", "/publicRooms"); 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. * @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: TODO * @return {module:client.Promise} Resolves: TODO
@@ -932,16 +923,24 @@ MatrixClient.prototype.login = function(loginType, data, callback) {
}; };
/** /**
* @param {string} loginType * @param {string} username
* @param {Object} data * @param {string} password
* @param {string} session_id
* @param {Object} auth
* @param {module:client.callback} callback Optional. * @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: TODO * @return {module:client.Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {module:http-api.MatrixError} Rejects: with an error response.
*/ */
MatrixClient.prototype.register = function(loginType, data, callback) { MatrixClient.prototype.register = function(username, password, session_id, auth, callback) {
data.type = loginType; if (auth === undefined) auth = {};
return this._http.authedRequest( auth.session = session_id;
callback, "POST", "/register", undefined, data return this._http.requestWithPrefix(
callback, "POST", "/register", undefined,
{
username: username,
password: password,
auth: auth
}, httpApi.PREFIX_V2_ALPHA
); );
}; };

View File

@@ -352,6 +352,7 @@ var requestCallback = function(defer, userDefinedCallback, onlyData) {
return function(err, response, body) { return function(err, response, body) {
if (!err && response.statusCode >= 400) { if (!err && response.statusCode >= 400) {
err = new module.exports.MatrixError(body); err = new module.exports.MatrixError(body);
err.httpStatus = response.statusCode;
} }
if (err) { if (err) {