Skip to content

Commit e762ab6

Browse files
committed
feat: [#44] new endpoint to change users passwords
1 parent 44c7c58 commit e762ab6

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/modes/rest/resources/torrent.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type UploadTorrentParams = {
5151
category: string
5252
description: string
5353
tags: Array<number>
54+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5455
file: any
5556
}
5657

@@ -102,6 +103,7 @@ export class TorrentResource implements IRestResource {
102103
}
103104

104105
async deleteTorrent(infoHash: string): Promise<DeleteTorrentResponseData> {
106+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
105107
return await fetchDelete<any, DeleteTorrentResponse>(
106108
`${this.client.apiBaseUrl}/torrent/${infoHash}`,
107109
{},

src/modes/rest/resources/user.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ type RegisterUserParams = {
2323
confirm_password: string
2424
}
2525

26+
type ChangePasswordParams = {
27+
current_password: string
28+
password: string
29+
confirm_password: string
30+
}
31+
2632
type Token = {
2733
token: string
2834
}
@@ -89,4 +95,21 @@ export class UserResource implements IRestResource {
8995
return Promise.reject(err.response?.data?.error ?? err);
9096
});
9197
}
98+
99+
async changePassword(params: ChangePasswordParams, username: string): Promise<boolean> {
100+
return await fetchPost<void>(
101+
`${this.client.apiBaseUrl}/user/${username}/change-password`,
102+
JSON.stringify(params),
103+
{
104+
"Authorization": `Bearer ${this.client.authToken}`,
105+
"Content-Type": "application/json"
106+
}
107+
)
108+
.then(() => {
109+
return Promise.resolve(true);
110+
})
111+
.catch((err) => {
112+
return Promise.reject(err.response?.data?.error ?? err);
113+
});
114+
}
92115
}

0 commit comments

Comments
 (0)