2024-05-20 21:56:48 +02:00
|
|
|
/*
|
|
|
|
Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Backend
|
|
|
|
Copyright (C) 2024 Christian Fraß
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with this program. If not, see
|
|
|
|
<https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-04-22 10:22:18 +02:00
|
|
|
namespace _espe.api
|
2024-04-22 10:02:34 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2024-04-29 22:40:52 +02:00
|
|
|
* @todo zeitliche Begrenzung?
|
2024-04-22 10:02:34 +02:00
|
|
|
*/
|
|
|
|
export function register_member_register(
|
|
|
|
rest_subject : lib_plankton.rest.type_rest
|
|
|
|
) : void
|
|
|
|
{
|
2024-05-15 08:38:58 +02:00
|
|
|
register<
|
2024-04-22 10:02:34 +02:00
|
|
|
{
|
2024-04-29 22:40:52 +02:00
|
|
|
email_use_veiled_address : boolean;
|
|
|
|
email_use_nominal_address : boolean;
|
|
|
|
email_redirect_to_private_address : boolean;
|
|
|
|
password : (null | string);
|
2024-05-27 21:27:36 +02:00
|
|
|
notification_target_url_template ?: (null | string);
|
2024-04-22 10:02:34 +02:00
|
|
|
},
|
2024-04-30 14:05:01 +02:00
|
|
|
Array<
|
|
|
|
{
|
|
|
|
incident : string;
|
|
|
|
details : Record<string, any>;
|
|
|
|
}
|
|
|
|
>
|
2024-04-22 10:02:34 +02:00
|
|
|
>(
|
|
|
|
rest_subject,
|
|
|
|
lib_plankton.http.enum_method.post,
|
2024-05-15 08:38:58 +02:00
|
|
|
"/member/register/:id",
|
2024-04-22 10:02:34 +02:00
|
|
|
{
|
|
|
|
"description": "nimmt zusätzliche Angaben eines Mitglieds entgegen",
|
2024-04-29 22:40:52 +02:00
|
|
|
"input_schema": () => ({
|
|
|
|
"type": "object",
|
|
|
|
"nullable": false,
|
|
|
|
"additionalProperties": false,
|
|
|
|
"properties": {
|
|
|
|
"email_use_veiled_address": {
|
|
|
|
"type": "boolean",
|
|
|
|
"nullable": false,
|
2024-05-21 19:58:00 +02:00
|
|
|
"description": "ob die nummern-basierte E-Mail-Adresse eingerichtet werden soll",
|
2024-04-29 22:40:52 +02:00
|
|
|
},
|
|
|
|
"email_use_nominal_address": {
|
|
|
|
"type": "boolean",
|
|
|
|
"nullable": false,
|
2024-05-21 19:58:00 +02:00
|
|
|
"description": "ob die namens-basierte E-Mail-Adresse eingerichtet werden soll",
|
2024-04-29 22:40:52 +02:00
|
|
|
},
|
|
|
|
"email_redirect_to_private_address": {
|
|
|
|
"type": "boolean",
|
|
|
|
"nullable": false,
|
2024-05-21 19:58:00 +02:00
|
|
|
"description": "ob auf die Partei-Adressen eingehende E-Mails zur privaten Adresse weitergeleitet werden sollen",
|
2024-04-29 22:40:52 +02:00
|
|
|
},
|
|
|
|
"password": {
|
|
|
|
"type": "string",
|
|
|
|
"nullable": true,
|
2024-05-21 19:58:00 +02:00
|
|
|
"description": "Passwort für alle Netz-Dienste",
|
2024-04-29 22:40:52 +02:00
|
|
|
},
|
2024-05-27 21:27:36 +02:00
|
|
|
"notification_target_url_template": {
|
|
|
|
"type": "string",
|
|
|
|
"nullable": true,
|
|
|
|
"description": "Platz-Halter: id"
|
|
|
|
},
|
2024-04-29 22:40:52 +02:00
|
|
|
},
|
|
|
|
"required": [
|
|
|
|
"email_use_veiled_address",
|
|
|
|
"email_use_nominal_address",
|
|
|
|
"email_redirect_to_private_address",
|
|
|
|
"password",
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
"output_schema": () => ({
|
2024-05-20 14:06:30 +02:00
|
|
|
"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",
|
|
|
|
]
|
|
|
|
}
|
2024-04-29 22:40:52 +02:00
|
|
|
}),
|
2024-04-22 10:02:34 +02:00
|
|
|
"query_parameters": [
|
|
|
|
{
|
2024-04-29 22:40:52 +02:00
|
|
|
"name": "key",
|
2024-04-22 10:02:34 +02:00
|
|
|
"required": true,
|
2024-04-29 22:40:52 +02:00
|
|
|
"description": "Zugriffs-Schlüssel",
|
2024-04-22 10:02:34 +02:00
|
|
|
},
|
|
|
|
],
|
2024-04-29 22:40:52 +02:00
|
|
|
"restriction": restriction_verification(
|
|
|
|
stuff => parseInt(stuff.path_parameters["id"]),
|
|
|
|
stuff => stuff.query_parameters["key"]
|
|
|
|
),
|
2024-04-30 14:05:01 +02:00
|
|
|
"execution": ({"path_parameters": path_parameters, "input": input}) => {
|
2024-05-27 17:32:42 +02:00
|
|
|
if (input === null) {
|
|
|
|
return Promise.reject(new Error("impossible"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const member_id : _espe.type.member_id = parseInt(path_parameters["id"]);
|
|
|
|
return (
|
|
|
|
_espe.service.member.register(
|
|
|
|
member_id,
|
|
|
|
{
|
|
|
|
"email_use_veiled_address": input.email_use_veiled_address,
|
|
|
|
"email_use_nominal_address": input.email_use_nominal_address,
|
|
|
|
"email_redirect_to_private_address": input.email_redirect_to_private_address,
|
|
|
|
"password": input.password,
|
2024-05-27 21:27:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"notification_target_url_template": (input.notification_target_url_template ?? null),
|
2024-05-27 17:32:42 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
.then(
|
|
|
|
flaws => Promise.resolve({
|
|
|
|
"status_code": (
|
|
|
|
(flaws.length <= 0)
|
|
|
|
? 200
|
|
|
|
: 409
|
|
|
|
),
|
|
|
|
"data": flaws
|
|
|
|
})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2024-04-22 10:02:34 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|