feat: add updatePassword api
This commit is contained in:
parent
ef3d0d3fbc
commit
7a3248b21b
|
@ -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<boolean | Error> {
|
||||
let ret: AxiosResponse<void>;
|
||||
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<void>): boolean {
|
||||
return ret.status === 200;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue