1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

User-Interactive auth for delete device

Allow app to pass in an auth dict on delete device
This commit is contained in:
Richard van der Hoff
2016-10-08 15:28:01 +01:00
parent e73051b230
commit d98867b810
2 changed files with 26 additions and 2 deletions

View File

@@ -747,16 +747,23 @@ MatrixBaseApis.prototype.setDeviceDetails = function(device_id, body) {
* Delete the given device * Delete the given device
* *
* @param {string} device_id device to delete * @param {string} device_id device to delete
* @param {object} auth Optional. Auth data to supply for User-Interactive auth.
* @return {module:client.Promise} Resolves: result object * @return {module:client.Promise} Resolves: result object
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {module:http-api.MatrixError} Rejects: with an error response.
*/ */
MatrixBaseApis.prototype.deleteDevice = function(device_id) { MatrixBaseApis.prototype.deleteDevice = function(device_id, auth) {
var path = utils.encodeUri("/devices/$device_id", { var path = utils.encodeUri("/devices/$device_id", {
$device_id: device_id, $device_id: device_id,
}); });
var body = {};
if (auth) {
body.auth = auth;
}
return this._http.authedRequestWithPrefix( return this._http.authedRequestWithPrefix(
undefined, "DELETE", path, undefined, undefined, undefined, "DELETE", path, undefined, body,
httpApi.PREFIX_UNSTABLE httpApi.PREFIX_UNSTABLE
); );
}; };

View File

@@ -383,6 +383,23 @@ describe("MatrixClient", function() {
httpBackend.flush(); httpBackend.flush();
}); });
}); });
describe("deleteDevice", function() {
var auth = {a: 1};
it("should pass through an auth dict", function(done) {
httpBackend.when(
"DELETE", "/_matrix/client/unstable/devices/my_device"
).check(function(req) {
expect(req.data).toEqual({auth: auth});
}).respond(200);
client.deleteDevice(
"my_device", auth
).catch(utils.failTest).done(done);
httpBackend.flush();
});
});
}); });
function assertObjectContains(obj, expected) { function assertObjectContains(obj, expected) {