Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for MSC2457 logout_devices param for setPassword() #2285

Merged
merged 6 commits into from
Apr 9, 2022
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7815,18 +7815,43 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* Make a request to change your password.
* @param {Object} authDict
* @param {string} newPassword The new desired password.
* @param {boolean} logoutDevices Should all sessions be logged out after the password change. Defaults to true.
* @param {module:client.callback} callback Optional.
* @return {Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
public setPassword(authDict: any, newPassword: string, callback?: Callback): Promise<any> { // TODO: Types
public setPassword(
authDict: any,
newPassword: string,
callback?: Callback,
): Promise<{}>;
public setPassword(
authDict: any,
newPassword: string,
logoutDevices: boolean,
callback?: Callback,
): Promise<{}>;
public setPassword(
authDict: any,
newPassword: string,
logoutDevices?: Callback | boolean,
callback?: Callback,
): Promise<{}> {
if (typeof logoutDevices === 'function') {
callback = logoutDevices;
}
if (typeof logoutDevices !== 'boolean') {
logoutDevices = true;
}

const path = "/account/password";
const data = {
'auth': authDict,
'new_password': newPassword,
'logout_devices': logoutDevices,
};

return this.http.authedRequest(
return this.http.authedRequest<{}>(
callback, Method.Post, path, null, data,
);
}
Expand Down