backend/source/api/actions/member_password_change_execute.ts

101 lines
2 KiB
TypeScript

namespace _espe.api
{
/**
* @todo ausgeklügelte Durchsatzratenbegrenzung
*/
export function register_member_password_change_execute(
rest_subject : lib_plankton.rest.type_rest
) : void
{
register<
{
token : string;
password_new : string;
},
Array<
{
incident : string;
details : Record<string, any>;
}
>
>(
rest_subject,
lib_plankton.http.enum_method.patch,
"/member/password_change/execute/:id",
{
"description": "Führt eine Passwort-Änderung für ein Mitglied durch",
"input_schema": () => ({
"nullable": false,
"type": "object",
"properties": {
"token": {
"nullable": false,
"type": "string"
},
"password_new": {
"nullable": false,
"type": "string",
"description": "das neue Passwort"
},
},
"additionalProperties": false,
"required": [
"token",
"password_new",
]
}),
"output_schema": () => ({
"nullable": false,
"type": "array",
"items": {
"nullable": false,
"type": "object",
"properties": {
"incident": {
"nullable": false,
"type": "string"
},
"details": {
"nullable": false,
"type": "object",
"properties": {},
"additionalProperties": {
"nullable": true
},
"required": []
},
},
"additionalProperties": false,
"required": [
"incident",
"details",
]
}
}),
"restriction": restriction_none,
"execution": ({"path_parameters": path_parameters, "input": input}) => {
const member_id : _espe.type.member_id = parseInt(path_parameters["id"]);
return (
_espe.service.member.password_change_execute(
member_id,
input.token,
input.password_new
)
.then(
flaws => Promise.resolve({
"status_code": (
(flaws.length <= 0)
? 200
: 409
),
"data": flaws
})
)
);
},
}
)
}
}