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": { "connections": {
"frontend_url_base": "http://localhost:8888", "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" "login_url": "https://login.example.org"
} }
}, },

View file

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

View file

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

View file

@ -35,7 +35,7 @@ namespace _espe.api
>( >(
rest_subject, rest_subject,
lib_plankton.http.enum_method.post, 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", "description": () => "führt die Anmeldung am System aus um geschützte Aktionen nutzen zu können",
"input_schema": () => ({ "input_schema": () => ({

View file

@ -67,7 +67,6 @@ namespace _espe.api
_espe.api.register_invitation_list(rest_subject); _espe.api.register_invitation_list(rest_subject);
_espe.api.register_invitation_read(rest_subject); _espe.api.register_invitation_read(rest_subject);
_espe.api.register_invitation_create(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_examine(rest_subject);
_espe.api.register_invitation_accept(rest_subject); _espe.api.register_invitation_accept(rest_subject);
} }

View file

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

View file

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

View file

@ -78,9 +78,11 @@ namespace _espe.service.invitation
}, },
{ {
"expiry": expiry = -1, "expiry": expiry = -1,
"notification_target_url_template": notification_target_url_template = null,
"send_immediatly": send_immediatly = true, "send_immediatly": send_immediatly = true,
} : { } : {
expiry ?: (null | int); expiry ?: (null | int);
notification_target_url_template ?: (null | string);
send_immediatly ?: boolean; send_immediatly ?: boolean;
} = { } = {
} }
@ -88,7 +90,6 @@ namespace _espe.service.invitation
{ {
id : _espe.type.invitation_id; id : _espe.type.invitation_id;
key : _espe.type.invitation_key; key : _espe.type.invitation_key;
url : (null | string);
} }
> >
{ {
@ -128,19 +129,6 @@ namespace _espe.service.invitation
"groups_value": groups_value, "groups_value": groups_value,
}; };
const invitation_id : _espe.type.invitation_id = await _espe.repository.invitation.create(invitation_object); 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 // send link
{ {
if (! send_immediatly) if (! send_immediatly)
@ -157,7 +145,7 @@ namespace _espe.service.invitation
(email_address_value !== "") (email_address_value !== "")
) )
&& &&
(url !== null) (notification_target_url_template !== null)
) )
) )
{ {
@ -166,13 +154,19 @@ namespace _espe.service.invitation
{ {
"details": { "details": {
"provided_address": email_address_value, "provided_address": email_address_value,
"url": url, "notification_target_url_template": notification_target_url_template,
}, },
} }
); );
} }
else else
{ {
const url : (null | string) = _espe.helpers.frontend_url_get(
notification_target_url_template,
{
"key": invitation_key,
}
);
try try
{ {
await _espe.helpers.email_send( await _espe.helpers.email_send(
@ -211,21 +205,10 @@ namespace _espe.service.invitation
return { return {
"id": invitation_id, "id": invitation_id,
"key": invitation_key, "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( 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_list.ts \
${dir_source}/api/actions/invitation_read.ts \ ${dir_source}/api/actions/invitation_read.ts \
${dir_source}/api/actions/invitation_create.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_examine.ts \
${dir_source}/api/actions/invitation_accept.ts \ ${dir_source}/api/actions/invitation_accept.ts \
${dir_source}/api/functions.ts \ ${dir_source}/api/functions.ts \