mirror of
https://github.com/classchartsapi/classcharts-api-js.git
synced 2026-05-14 11:58:13 +00:00
feat: add changePassword (parent app) endpoint
This commit is contained in:
parent
c42dd71cdf
commit
b37e3dc94b
2 changed files with 28 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import type { GetPupilsResponse } from "../types.ts";
|
import type { ChangePasswordResponse, GetPupilsResponse } from "../types.ts";
|
||||||
|
|
||||||
import { BaseClient } from "../core/baseClient.ts";
|
import { BaseClient } from "../core/baseClient.ts";
|
||||||
import { API_BASE_PARENT, BASE_URL } from "../utils/consts.ts";
|
import { API_BASE_PARENT, BASE_URL } from "../utils/consts.ts";
|
||||||
|
|
@ -88,4 +88,29 @@ export class ParentClient extends BaseClient {
|
||||||
}
|
}
|
||||||
throw new Error("No pupil with specified ID returned");
|
throw new Error("No pupil with specified ID returned");
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Changes the login password for this parent's account
|
||||||
|
* @param current Current password
|
||||||
|
* @param new New password
|
||||||
|
* @returns whether it was successful or not
|
||||||
|
*/
|
||||||
|
async changePassword(this: ParentClient, current: string, newPassword: string): Promise<ChangePasswordResponse>{
|
||||||
|
const formData = new URLSearchParams();
|
||||||
|
formData.append("current", current);
|
||||||
|
formData.append("new", newPassword);
|
||||||
|
formData.append("repeat", newPassword);
|
||||||
|
const headers = new Headers({
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
await this.makeAuthedRequest(
|
||||||
|
this.API_BASE + "/password",
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
headers: headers,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -490,6 +490,8 @@ export interface PupilFieldsData {
|
||||||
|
|
||||||
export type PupilFieldsResponse = ClassChartsResponse<PupilFieldsData, []>;
|
export type PupilFieldsResponse = ClassChartsResponse<PupilFieldsData, []>;
|
||||||
|
|
||||||
|
export type ChangePasswordResponse = ClassChartsResponse<[], []>;
|
||||||
|
|
||||||
export interface GetStudentCodeOptions {
|
export interface GetStudentCodeOptions {
|
||||||
/**
|
/**
|
||||||
* Date of birth, in format YYYY-MM-DD
|
* Date of birth, in format YYYY-MM-DD
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue