Compare commits

..

No commits in common. "085d255ae75975b0175871e1dd6786321957cc7b" and "7c9f856aa1739f5ff8f9b86f5385f70ee9e19f31" have entirely different histories.

11 changed files with 58 additions and 231 deletions

View file

@ -56,8 +56,6 @@
},
"connections": {
"frontend_url_base": "http://localhost:8888",
"frontend_path_template_invitation_handle": "/#invitation_handle,key={{key}}",
"frontend_path_template_password_change": "/#password_change_exec,id={{id}},key={{key}}",
"login_url": "https://login.example.org"
}
},

View file

@ -52,31 +52,20 @@ namespace _espe.api
"type": "intiger",
"description": "ID"
},
"preview": {
"name": {
"nullable": false,
"type": "object",
"properties": {
"name": {
"nullable": false,
"type": "string",
"description": "Name"
},
"label": {
"nullable": false,
"type": "string",
"description": "Beschriftung"
},
},
"additionalProperties": false,
"required": [
"name",
"label",
]
"type": "string",
"description": "Name"
},
"label": {
"nullable": false,
"type": "string",
"description": "Beschriftung"
},
},
"required": [
"id",
"preview",
"name",
]
}),
"restriction": () => restriction_none,

View file

@ -35,6 +35,7 @@ namespace _espe.api
groups_value : Array<int>;
expiry : (null | int);
};
notification_target_url_template ?: (null | string);
send_immediatly : boolean;
},
(
@ -43,7 +44,6 @@ namespace _espe.api
{
id : _espe.type.member_id;
key : string;
url : (null | string);
}
)
>(
@ -117,6 +117,11 @@ namespace _espe.api
"expiry",
]
},
"notification_target_url_template": {
"type": "string",
"nullable": true,
"description": "Platz-Halter: key"
},
"send_immediatly": {
"nullable": false,
"type": "boolean",
@ -140,31 +145,20 @@ namespace _espe.api
"type": "string",
"nullable": false,
},
"url": {
"type": "string",
"nullable": true,
},
},
"additionalProperties": false,
"required": [
"id",
"key",
"url",
]
}),
"restriction": () => restriction_logged_in,
"execution": () => async ({"input": input}) => {
if (input === null)
{
if (input === null) {
return Promise.reject(new Error("impossible"));
}
else
{
const invitation_info : {
id : _espe.type.invitation_id;
key : _espe.type.invitation_key;
url : (null | string);
} = await _espe.service.invitation.create(
else {
const invitation_info : {id : _espe.type.invitation_id; key : _espe.type.invitation_key;} = await _espe.service.invitation.create(
{
"name_changeable": input.data.name_changeable,
"name_value": input.data.name_value,
@ -177,15 +171,14 @@ namespace _espe.api
},
{
"expiry": input.data.expiry,
"notification_target_url_template": input.notification_target_url_template,
"send_immediatly": input.send_immediatly,
}
);
return Promise.resolve(
{
"status_code": 201,
"data": invitation_info
}
);
return Promise.resolve({
"status_code": 201,
"data": invitation_info
});
}
}
}

View file

@ -1,69 +0,0 @@
/*
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/>.
*/
namespace _espe.api
{
/**
*/
export function register_invitation_delete(
rest_subject : lib_plankton.rest_http.type_rest
) : void
{
lib_plankton.rest_http.register<
int,
null
>(
rest_subject,
lib_plankton.http.enum_method.delete,
_espe.api.full_path("/invitation/delete"),
{
/**
* @todo translation
*/
"description": () => "löscht eine Einladung",
"input_schema": () => ({
"nullable": false,
"type": "integer",
}),
"output_schema": () => ({
"nullable": true,
}),
"restriction": () => restriction_logged_in,
"execution": () => async (stuff) => {
if (stuff.input === null)
{
return Promise.reject(new Error("impossible"));
}
else
{
const invitation_id : _espe.type.invitation_id = stuff.input;
await _espe.service.invitation.remove(
invitation_id
);
return Promise.resolve(
{
"status_code": 200,
"data": null
}
);
}
}
}
);
}
}

View file

@ -62,22 +62,15 @@ namespace _espe.api
}),
"restriction": () => restriction_none,
"execution": () => async ({"input": input}) => {
if (input === null)
{
if (input === null) {
return Promise.reject(new Error("impossible"));
}
else
{
await _espe.service.member.password_change_initialize(
input.identifier,
input.url_template
);
return Promise.resolve(
{
"status_code": 200,
"data": null
}
);
else {
await _espe.service.member.password_change_initialize(input.identifier, input.url_template);
return Promise.resolve({
"status_code": 200,
"data": null
});
}
},
}

View file

@ -35,7 +35,7 @@ namespace _espe.api
>(
rest_subject,
lib_plankton.http.enum_method.post,
_espe.api.full_path("/session/begin"),
_espe.conf.get().server.path_base + "/session/begin",
{
"description": () => "führt die Anmeldung am System aus um geschützte Aktionen nutzen zu können",
"input_schema": () => ({

View file

@ -67,7 +67,6 @@ namespace _espe.api
_espe.api.register_invitation_list(rest_subject);
_espe.api.register_invitation_read(rest_subject);
_espe.api.register_invitation_create(rest_subject);
_espe.api.register_invitation_delete(rest_subject);
_espe.api.register_invitation_examine(rest_subject);
_espe.api.register_invitation_accept(rest_subject);
}

View file

@ -161,8 +161,6 @@ namespace _espe.conf
};
connections : {
frontend_url_base : (null | string);
frontend_path_template_invitation_handle : (null | string);
frontend_path_template_password_change : (null | string);
login_url : (null | string);
};
};
@ -210,7 +208,7 @@ namespace _espe.conf
conf_raw : any
) : void
{
const version : int = (conf_raw["version"] ?? 6);
const version : int = (conf_raw["version"] ?? 5);
_data = {
"general": (
((node_general) => ({
@ -221,8 +219,7 @@ namespace _espe.conf
"log": (
(() => {
switch (version) {
case 1:
{
case 1: {
return [
{
"kind": "stdout",
@ -236,9 +233,7 @@ namespace _espe.conf
case 2:
case 3:
case 4:
case 5:
case 6:
{
case 5: {
const node_log = (
conf_raw["log"]
??
@ -275,15 +270,12 @@ namespace _espe.conf
switch (version) {
case 1:
case 2:
case 3:
{
case 3: {
return "::";
break;
}
case 4:
case 5:
case 6:
{
case 5: {
return (node_server["host"] ?? "::");
break
}
@ -298,8 +290,7 @@ namespace _espe.conf
const kind : string = (node_database["kind"] ?? "sqlite");
const node_database_data_raw = (node_database["data"] ?? {});
switch (kind) {
case "sqlite":
{
case "sqlite": {
return {
"kind": kind,
"data": {
@ -308,16 +299,14 @@ namespace _espe.conf
};
break;
}
case "postgresql":
{
case "postgresql": {
return {
"kind": kind,
"data": node_database_data_raw,
};
break;
}
default:
{
default: {
throw (new Error("unhandled"));
break;
}
@ -329,8 +318,7 @@ namespace _espe.conf
const kind : string = (node_email_sending["kind"] ?? "console");
const data_raw = (node_email_sending["data"] ?? {});
switch (kind) {
case "regular":
{
case "regular": {
return {
"kind": kind,
"data": {
@ -340,8 +328,7 @@ namespace _espe.conf
};
break;
}
case "redirect":
{
case "redirect": {
return {
"kind": kind,
"data": {
@ -352,8 +339,7 @@ namespace _espe.conf
};
break;
}
case "console":
{
case "console": {
return {
"kind": kind,
"data": {
@ -361,8 +347,7 @@ namespace _espe.conf
};
break;
}
case "drop":
{
case "drop": {
return {
"kind": kind,
"data": {
@ -370,8 +355,7 @@ namespace _espe.conf
};
break;
}
default:
{
default: {
throw (new Error("unhandled"));
break;
}
@ -416,44 +400,6 @@ namespace _espe.conf
"connections": (
((node_settings_connections) => ({
"frontend_url_base": (node_settings_connections["frontend_url_base"] ?? null),
"frontend_path_template_password_change": (() => {
switch (version)
{
case 1:
case 2:
case 3:
case 4:
case 5:
{
return null;
break;
}
case 6:
{
return (node_settings_connections["frontend_path_template_password_change"] ?? null);
break;
}
}
}) (),
"frontend_path_template_invitation_handle": (() => {
switch (version)
{
case 1:
case 2:
case 3:
case 4:
case 5:
{
return null;
break;
}
case 6:
{
return (node_settings_connections["frontend_path_template_invitation_handle"] ?? null);
break;
}
}
}) (),
"login_url": (node_settings_connections["login_url"] ?? null),
})) (node_settings["connections"] ?? {})
),
@ -462,8 +408,7 @@ namespace _espe.conf
"outputs": (() => {
switch (version) {
case 1:
case 2:
{
case 2: {
const node_output = (conf_raw["output"] ?? {});
return (
("authelia" in node_output)
@ -482,15 +427,12 @@ namespace _espe.conf
);
break;
}
case 3:
{
case 3: {
return (conf_raw["outputs"] ?? []);
break;
}
case 4:
case 5:
case 6:
{
case 5: {
const node_outputs = (conf_raw["outputs"] ?? []);
return node_outputs.map(
(output_description : {kind : string; data : any;}) => {

View file

@ -259,7 +259,7 @@ namespace _espe.helpers
}
else {
return lib_plankton.string.coin(
"{{base}}{{rest}}",
"{{base}}/{{rest}}",
{
"base": frontend_url_base,
"rest": lib_plankton.string.coin(template, arguments_),

View file

@ -78,9 +78,11 @@ namespace _espe.service.invitation
},
{
"expiry": expiry = -1,
"notification_target_url_template": notification_target_url_template = null,
"send_immediatly": send_immediatly = true,
} : {
expiry ?: (null | int);
notification_target_url_template ?: (null | string);
send_immediatly ?: boolean;
} = {
}
@ -88,7 +90,6 @@ namespace _espe.service.invitation
{
id : _espe.type.invitation_id;
key : _espe.type.invitation_key;
url : (null | string);
}
>
{
@ -128,19 +129,6 @@ namespace _espe.service.invitation
"groups_value": groups_value,
};
const invitation_id : _espe.type.invitation_id = await _espe.repository.invitation.create(invitation_object);
const frontend_path_template_invitation_handle : (null | string) = _espe.conf.get().settings.connections.frontend_path_template_invitation_handle;
const url : (null | string) = (
(frontend_path_template_invitation_handle === null)
?
null
:
_espe.helpers.frontend_url_get(
frontend_path_template_invitation_handle,
{
"key": invitation_key,
}
)
);
// send link
{
if (! send_immediatly)
@ -157,7 +145,7 @@ namespace _espe.service.invitation
(email_address_value !== "")
)
&&
(url !== null)
(notification_target_url_template !== null)
)
)
{
@ -166,13 +154,19 @@ namespace _espe.service.invitation
{
"details": {
"provided_address": email_address_value,
"url": url,
"notification_target_url_template": notification_target_url_template,
},
}
);
}
else
{
const url : (null | string) = _espe.helpers.frontend_url_get(
notification_target_url_template,
{
"key": invitation_key,
}
);
try
{
await _espe.helpers.email_send(
@ -211,21 +205,10 @@ namespace _espe.service.invitation
return {
"id": invitation_id,
"key": invitation_key,
"url": url,
};
}
/**
*/
export function remove(
id : _espe.type.invitation_id
) : Promise<void>
{
return _espe.repository.invitation.delete_(id);
}
/**
*/
export function get_by_id(

View file

@ -74,7 +74,6 @@ ${dir_temp}/espe-core.js ${dir_temp}/espe-core.d.ts: \
${dir_source}/api/actions/invitation_list.ts \
${dir_source}/api/actions/invitation_read.ts \
${dir_source}/api/actions/invitation_create.ts \
${dir_source}/api/actions/invitation_delete.ts \
${dir_source}/api/actions/invitation_examine.ts \
${dir_source}/api/actions/invitation_accept.ts \
${dir_source}/api/functions.ts \