diff --git a/src/account.ts b/src/account.ts index 28db13c..a28e756 100644 --- a/src/account.ts +++ b/src/account.ts @@ -29,6 +29,7 @@ import { postApiAuthLogout, getApiUploadLimit, postApiAccountUpdateEmail, + postApiAccountUpdatePassword, } from "./account/generated/index.js"; import { AxiosError, AxiosResponse } from "axios"; @@ -247,6 +248,23 @@ export class AccountApi { return this.checkSuccessBool(ret); } + public async updatePassword( + currentPasswprd: string, + newPassword: string, + ): Promise { + let ret: AxiosResponse; + try { + ret = await postApiAccountUpdatePassword( + { current_password: currentPasswprd, new_password: newPassword }, + this.buildOptions(), + ); + } catch (e) { + return new Error((e as AxiosError).response?.data as string); + } + + return this.checkSuccessBool(ret); + } + private checkSuccessBool(ret: AxiosResponse): boolean { return ret.status === 200; } diff --git a/src/account/swagger.yaml b/src/account/swagger.yaml index 47a877a..1aafb01 100644 --- a/src/account/swagger.yaml +++ b/src/account/swagger.yaml @@ -160,6 +160,18 @@ paths: responses: "200": description: Email updated successfully + /api/account/update-password: + post: + summary: Update password + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/UpdatePasswordRequest" + responses: + "200": + description: Password updated successfully /api/upload-limit: get: summary: Get the basic file upload (POST) upload limit set by the portal @@ -270,6 +282,16 @@ components: type: string password: type: string + UpdatePasswordRequest: + type: object + required: + - current_password + - new_password + properties: + current_password: + type: string + new_password: + type: string PingResponse: type: object properties: