Adding change password endpoint.

This commit is contained in:
Dessalines 2021-04-01 17:35:37 -04:00
parent 96a6d3ff3f
commit 0ef7f5001c
4 changed files with 18 additions and 3 deletions

View file

@ -89,6 +89,7 @@ import {
PrivateMessagesResponse,
Register,
SaveUserSettings,
ChangePassword,
PersonMentionResponse,
} from './interfaces/api/person';
@ -363,6 +364,10 @@ export class LemmyHttp {
return this.wrapper(HttpType.Put, '/user/save_user_settings', form);
}
async changePassword(form: ChangePassword): Promise<LoginResponse> {
return this.wrapper(HttpType.Put, '/user/change_password', form);
}
async addAdmin(form: AddAdmin): Promise<AddAdminResponse> {
return this.wrapper(HttpType.Post, '/admin/add', form);
}

View file

@ -50,14 +50,18 @@ export interface SaveUserSettings {
email?: string;
bio?: string;
matrix_user_id?: string;
new_password?: string; // If setting a new password, you need all 3 password fields
new_password_verify?: string;
old_password?: string;
show_avatars: boolean;
send_notifications_to_email: boolean;
auth: string;
}
export interface ChangePassword {
new_password: string;
new_password_verify: string;
old_password: string;
auth: string;
}
/**
* The `jwt` string should be stored and used anywhere `auth` is called for.
*/

View file

@ -63,6 +63,7 @@ export enum UserOperation {
SaveSiteConfig,
PostJoin,
CommunityJoin,
ChangePassword,
}
export enum SortType {

View file

@ -62,6 +62,7 @@ import {
PasswordReset,
Register,
SaveUserSettings,
ChangePassword,
} from './interfaces/api/person';
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
import { UserOperation } from './interfaces/others';
@ -272,6 +273,10 @@ export class LemmyWebsocket {
return wrapper(UserOperation.SaveUserSettings, form);
}
changePassword(form: ChangePassword) {
return wrapper(UserOperation.ChangePassword, form);
}
deleteAccount(form: DeleteAccount) {
return wrapper(UserOperation.DeleteAccount, form);
}