diff --git a/lib/base-apis.js b/lib/base-apis.js index 497859a91..4f8d4778d 100644 --- a/lib/base-apis.js +++ b/lib/base-apis.js @@ -128,6 +128,28 @@ MatrixBaseApis.prototype.logout = function(callback) { ); }; +/** + * Deactivates the logged-in account. + * Obviously, further calls that require authorisation should fail after this + * method is called. The state of the MatrixClient object is not affected: + * it is up to the caller to either reset or destroy the MatrixClient after + * this method succeeds. + * @param {object} auth Optional. Auth data to supply for User-Interactive auth. + * @param {module:client.callback} callback Optional. + * @return {module:client.Promise} Resolves: On success, the empty object + */ +MatrixBaseApis.prototype.deactivateAccount = function(auth, callback) { + var body = {}; + if (auth) { + body = { + auth: auth, + } + } + return this._http.authedRequestWithPrefix( + callback, "POST", '/account/deactivate', undefined, body, httpApi.PREFIX_UNSTABLE + ); +}; + // Room operations // ===============