Compare commits

..

15 commits

Author SHA1 Message Date
fenris 085d255ae7 [add] api:invitation_delete [mod] Frontend-URL-Templates nun in Konfiguration statt als Parameter von außen (conf 5 -> 6) 2025-10-05 23:24:47 +02:00
fenris 4538782d80 [mod] api:session_begin:eigens vorgesehene Funktion zum Zustammenstellen des Pfads nutzer 2025-10-05 22:42:46 +02:00
fenris cc244ad576 [fix] api:group_list:output_schema 2025-10-05 22:41:26 +02:00
fenris 8d803cbec1 [sty] api:member_password_change_initialize 2025-10-05 22:40:54 +02:00
fenris 7c9f856aa1 [mod] readme 2025-09-26 11:57:19 +02:00
fenris 79253873be [fix] tools:deploy 2025-09-22 21:26:50 +02:00
fenris 1ed2f003e4 [mod] readme 2025-09-22 21:26:42 +02:00
Christian Fraß ff5449766a [mod] Datei-Name der Beispiel-Konfiguration angepasst 2025-08-26 07:54:23 +00:00
Christian Fraß 547c957f42 [mod] Bei Annahme der Einladung E-Mails an Mitglied und Admins senden 2025-08-25 22:33:11 +00:00
Christian Fraß abd703981f [del] conf:settings.misc 2025-08-25 20:40:56 +00:00
Christian Fraß d77f0299b9 [del] conf:settings.name_index 2025-08-25 20:39:15 +00:00
Christian Fraß 9006170bdf [del] conf:settings.email 2025-08-25 20:38:20 +00:00
Christian Fraß 2485e9c680 [mod] invitation_handle 2025-08-25 14:08:20 +00:00
Christian Fraß d712412ac5 [mod] Gruppen und Mitglieder sortiert ausgeben 2025-08-25 13:00:43 +00:00
Christian Fraß aa17938c6e Einladungs-System (#6)
## Aufgaben

- [\#193](https://vikunja.ramsch.sx/tasks/193)

## Zugehörige MRs

- https://forgejo.linke.sx/espe/datamodel/pulls/3
- https://forgejo.linke.sx/espe/frontend-zackeneule/pulls/2

Reviewed-on: https://forgejo.linke.sx/espe/backend/pulls/6
Co-authored-by: Christian Fraß <christian.frass@dielinke-glauchau.de>
Co-committed-by: Christian Fraß <christian.frass@dielinke-glauchau.de>
2025-08-25 14:22:56 +02:00
20 changed files with 357 additions and 245 deletions

View file

@ -44,14 +44,6 @@
"name": "Example Orginsation", "name": "Example Orginsation",
"domain": "example.org" "domain": "example.org"
}, },
"misc": {
"prefix_for_veiled_email_addresses": "member-",
"facultative_membership_number": true,
"auto_register": true
},
"summon_email": {
"remark": null
},
"password_policy": { "password_policy": {
"minimum_length": 4, "minimum_length": 4,
"maximum_length": 12, "maximum_length": 12,
@ -62,13 +54,11 @@
"password_change": { "password_change": {
"cooldown_time": 300 "cooldown_time": 300
}, },
"name_index": {
"veil": false,
"salt": null
},
"connections": { "connections": {
"frontend_url_base": "http://localhost:8888", "frontend_url_base": "http://localhost:8888",
"login_url": null "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"
} }
}, },
"outputs": [ "outputs": [

View file

@ -39,21 +39,24 @@
"name": "alexandra", "name": "alexandra",
"label": "Alexandra Ahorn", "label": "Alexandra Ahorn",
"email_address": "alex-rockt@example.org", "email_address": "alex-rockt@example.org",
"groups": [1, 2, 3] "groups": [1, 2, 3],
"password": "aaa111"
}, },
{ {
"id": 2, "id": 2,
"name": "berthold", "name": "berthold",
"label": "Berthold Buche", "label": "Berthold Buche",
"email_address": "bert-ohne-ernie@example.org", "email_address": "bert-ohne-ernie@example.org",
"groups": [4, 5, 2] "groups": [4, 5, 2],
"password": "bbb222"
}, },
{ {
"id": 3, "id": 3,
"name": "charlotte", "name": "charlotte",
"label": "Charlotte Castania", "label": "Charlotte Castania",
"email_address": "charly-the-unicorn@example.org", "email_address": "charly-the-unicorn@example.org",
"groups": [4, 1] "groups": [4, 1],
"password": "ccc333"
} }
], ],
"invitations": [ "invitations": [

View file

@ -2,7 +2,7 @@
## Beschreibung ## Beschreibung
- Hintergrund-Dienst für [Espe](https://gitlab.die-linke.cloud/espe/documentation) - Hintergrund-Dienst für [Espe](/espe/meta)
## Erstellung ## Erstellung

View file

@ -52,23 +52,34 @@ namespace _espe.api
"type": "intiger", "type": "intiger",
"description": "ID" "description": "ID"
}, },
"name": { "preview": {
"nullable": false, "nullable": false,
"type": "string", "type": "object",
"description": "Name" "properties": {
}, "name": {
"label": { "nullable": false,
"nullable": false, "type": "string",
"type": "string", "description": "Name"
"description": "Beschriftung" },
"label": {
"nullable": false,
"type": "string",
"description": "Beschriftung"
},
},
"additionalProperties": false,
"required": [
"name",
"label",
]
}, },
}, },
"required": [ "required": [
"id", "id",
"name", "preview",
] ]
}), }),
"restriction": () => restriction_logged_in, "restriction": () => restriction_none,
"execution": () => async ({}) => { "execution": () => async ({}) => {
const data = await _espe.service.group.list(); const data = await _espe.service.group.list();
return Promise.resolve({ return Promise.resolve({

View file

@ -35,7 +35,6 @@ 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;
}, },
( (
@ -44,6 +43,7 @@ namespace _espe.api
{ {
id : _espe.type.member_id; id : _espe.type.member_id;
key : string; key : string;
url : (null | string);
} }
) )
>( >(
@ -117,11 +117,6 @@ 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",
@ -145,20 +140,31 @@ 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,
@ -171,14 +177,15 @@ 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, {
"data": invitation_info "status_code": 201,
}); "data": invitation_info
}
);
} }
} }
} }

View file

@ -0,0 +1,69 @@
/*
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,15 +62,22 @@ 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); {
return Promise.resolve({ await _espe.service.member.password_change_initialize(
"status_code": 200, input.identifier,
"data": null input.url_template
}); );
return Promise.resolve(
{
"status_code": 200,
"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.conf.get().server.path_base + "/session/begin", _espe.api.full_path("/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,6 +67,7 @@ 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

@ -149,14 +149,6 @@ namespace _espe.conf
name : string; name : string;
domain : string; domain : string;
}; };
misc : {
prefix_for_veiled_email_addresses : string;
facultative_membership_number : boolean;
auto_register : boolean;
};
summon_email : {
remark : string;
};
password_policy : { password_policy : {
minimum_length : (null | int); minimum_length : (null | int);
maximum_length : (null | int); maximum_length : (null | int);
@ -167,12 +159,10 @@ namespace _espe.conf
password_change : { password_change : {
cooldown_time : int; cooldown_time : int;
}; };
name_index : {
veil : boolean;
salt : (null | string);
};
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);
}; };
}; };
@ -220,7 +210,7 @@ namespace _espe.conf
conf_raw : any conf_raw : any
) : void ) : void
{ {
const version : int = (conf_raw["version"] ?? 5); const version : int = (conf_raw["version"] ?? 6);
_data = { _data = {
"general": ( "general": (
((node_general) => ({ ((node_general) => ({
@ -231,7 +221,8 @@ namespace _espe.conf
"log": ( "log": (
(() => { (() => {
switch (version) { switch (version) {
case 1: { case 1:
{
return [ return [
{ {
"kind": "stdout", "kind": "stdout",
@ -245,7 +236,9 @@ 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"]
?? ??
@ -282,12 +275,15 @@ 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
} }
@ -302,7 +298,8 @@ 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": {
@ -311,14 +308,16 @@ 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;
} }
@ -330,7 +329,8 @@ 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,7 +340,8 @@ namespace _espe.conf
}; };
break; break;
} }
case "redirect": { case "redirect":
{
return { return {
"kind": kind, "kind": kind,
"data": { "data": {
@ -351,7 +352,8 @@ namespace _espe.conf
}; };
break; break;
} }
case "console": { case "console":
{
return { return {
"kind": kind, "kind": kind,
"data": { "data": {
@ -359,7 +361,8 @@ namespace _espe.conf
}; };
break; break;
} }
case "drop": { case "drop":
{
return { return {
"kind": kind, "kind": kind,
"data": { "data": {
@ -367,7 +370,8 @@ namespace _espe.conf
}; };
break; break;
} }
default: { default:
{
throw (new Error("unhandled")); throw (new Error("unhandled"));
break; break;
} }
@ -387,18 +391,6 @@ namespace _espe.conf
"name": ((node_settings["organisation"] ?? {})["name"] ?? "Example Orginsation"), // TODO: mandatory? "name": ((node_settings["organisation"] ?? {})["name"] ?? "Example Orginsation"), // TODO: mandatory?
"domain": ((node_settings["organisation"] ?? {})["domain"] ?? "example.org"), // TODO: mandatory? "domain": ((node_settings["organisation"] ?? {})["domain"] ?? "example.org"), // TODO: mandatory?
}, },
"misc": (
((node_settings_misc) => ({
"prefix_for_veiled_email_addresses": (node_settings_misc["prefix_for_veiled_email_addresses"] ?? "member-"),
"facultative_membership_number": (node_settings_misc["facultative_membership_number"] ?? false),
"auto_register": (node_settings_misc["auto_register"] ?? false),
})) (node_settings["misc"] ?? {})
),
"summon_email": (
((node_settings_summon_email) => ({
"remark": (node_settings_summon_email["remark"] ?? null),
})) (node_settings["summon_email"] ?? {})
),
"password_policy": ( "password_policy": (
((node_settings_password_policy) => ({ ((node_settings_password_policy) => ({
"minimum_length": ( "minimum_length": (
@ -412,8 +404,8 @@ namespace _espe.conf
: 240 : 240
), ),
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true), "must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true), "must_contain_number": (node_settings_password_policy["must_contain_number"] ?? false),
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true), "must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? false),
})) (node_settings["password_policy"] ?? {}) })) (node_settings["password_policy"] ?? {})
), ),
"password_change": ( "password_change": (
@ -421,15 +413,47 @@ namespace _espe.conf
"cooldown_time": (node_settings_password_change["cooldown_time"] ?? 86400), "cooldown_time": (node_settings_password_change["cooldown_time"] ?? 86400),
})) (node_settings["password_change"] ?? {}) })) (node_settings["password_change"] ?? {})
), ),
"name_index": (
((node_settings_password_policy) => ({
"veil": (node_settings_password_policy["veil"] ?? true),
"salt": (node_settings_password_policy["salt"] ?? ""),
})) (node_settings["name_index"] ?? {})
),
"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"] ?? {})
), ),
@ -438,7 +462,8 @@ 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)
@ -457,12 +482,15 @@ 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

@ -3,10 +3,8 @@
"identifier": "deu" "identifier": "deu"
}, },
"tree": { "tree": {
"email.summon.subject": "Registrierung",
"email.summon.body": "Hi, {{name}}\n\n{{remark}}\n\nWenn du die Dienste nutzen möchtest, rufe bitte folgende Adresse auf:\n\n{{url}}",
"email.registration.subject": "Registrierung erfolgt", "email.registration.subject": "Registrierung erfolgt",
"email.registration.body": "Das Mitglied '{{name_display}}' hat sich soeben registriert:\n\n{{url}}", "email.registration.body": "'{{name}}' ('{{label}}') wurde soeben registriert",
"email.activation.subject": "Freischaltung erfolgt", "email.activation.subject": "Freischaltung erfolgt",
"email.activation.body": "Hi, {{name_display}}\n\nDein Mitglieder-Konto wurde gerade freigeschalten. Du kannst dich nun anmelden:\n\nURL: {{url}}\nAnmelde-Name: {{name_login}}\n{{password_info}}", "email.activation.body": "Hi, {{name_display}}\n\nDein Mitglieder-Konto wurde gerade freigeschalten. Du kannst dich nun anmelden:\n\nURL: {{url}}\nAnmelde-Name: {{name_login}}\n{{password_info}}",
"email.activation.password_info": "Passwort: {{password}}\n\nBitte ändere dein Passwort zeitnah!", "email.activation.password_info": "Passwort: {{password}}\n\nBitte ändere dein Passwort zeitnah!",
@ -15,7 +13,7 @@
"email.password_change.execution.subject": "Passwort-Änderung abgeschlossen", "email.password_change.execution.subject": "Passwort-Änderung abgeschlossen",
"email.password_change.execution.body": "Hi, {{name}}\n\nDein Passwort wurde soeben geändert.\n", "email.password_change.execution.body": "Hi, {{name}}\n\nDein Passwort wurde soeben geändert.\n",
"email.invitation.subject": "Einladung", "email.invitation.subject": "Einladung",
"email.invitation.body": "{{url}}", "email.invitation.body": "Du wurdest zu {{organisation}} eingeladen. Um beizutreten, rufe bitte folgende Adresse auf:\n\n{{url}}",
"help.args.action.description": "auszuführende Aktion; Auswahl", "help.args.action.description": "auszuführende Aktion; Auswahl",
"help.args.action.options.serve": "Server starten", "help.args.action.options.serve": "Server starten",
"help.args.action.options.api_doc": "API-Dokumentation gemäß OpenAPI-Spezifikation auf Standard-Ausgabe schreiben", "help.args.action.options.api_doc": "API-Dokumentation gemäß OpenAPI-Spezifikation auf Standard-Ausgabe schreiben",

View file

@ -3,10 +3,8 @@
"identifier": "eng" "identifier": "eng"
}, },
"tree": { "tree": {
"email.summon.subject": "Registration",
"email.summon.body": "Hi, {{name}}\n\n{{remark}}\n\nIn case you want to use online service, open the following link:\n\n{{url}}",
"email.registration.subject": "Registration received", "email.registration.subject": "Registration received",
"email.registration.body": "The member '{{name_display}}' just registered:\n\n{{url}}", "email.registration.body": "'{{name}}' ('{{label}}') just has been registered",
"email.activation.subject": "Activated", "email.activation.subject": "Activated",
"email.activation.body": "Hi, {{name_display}}\n\nYour account has just been activated. You may login now:\n\nURL: {{url}}\nLogin name: {{name_login}}\n{{password_info}}", "email.activation.body": "Hi, {{name_display}}\n\nYour account has just been activated. You may login now:\n\nURL: {{url}}\nLogin name: {{name_login}}\n{{password_info}}",
"email.activation.password_info": "Password: {{password}}\n\nPlease change your password soon!", "email.activation.password_info": "Password: {{password}}\n\nPlease change your password soon!",
@ -15,7 +13,7 @@
"email.password_change.execution.subject": "Password change concluded", "email.password_change.execution.subject": "Password change concluded",
"email.password_change.execution.body": "Hi, {{name}}\n\nYour password has just been changed.\n", "email.password_change.execution.body": "Hi, {{name}}\n\nYour password has just been changed.\n",
"email.invitation.subject": "invitation", "email.invitation.subject": "invitation",
"email.invitation.body": "{{url}}", "email.invitation.body": "You have been invited to {{organisation}}. In order to join, please open the following address:\n\n{{url}}",
"help.args.action.description": "action to executo; options", "help.args.action.description": "action to executo; options",
"help.args.action.options.serve": "start server", "help.args.action.options.serve": "start server",
"help.args.action.options.api_doc": "write API documentation according to OpenAPI specification to stdout", "help.args.action.options.api_doc": "write API documentation according to OpenAPI specification to stdout",

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

@ -41,6 +41,7 @@ namespace _espe.sample
label : string; label : string;
email_address : (null | string); email_address : (null | string);
groups : Array<int>; groups : Array<int>;
password : string;
} }
>; >;
invitations : Array< invitations : Array<
@ -94,15 +95,19 @@ namespace _espe.sample
{ {
for (const member_raw of data.members) for (const member_raw of data.members)
{ {
const member_id : _espe.type.member_id = await _espe.service.member.project( const member_id : _espe.type.member_id = await _espe.service.member.add(
{ {
"name": member_raw.name, "name": member_raw.name,
"label": member_raw.label, "label": member_raw.label,
"email_address": member_raw.email_address, "email_address": member_raw.email_address,
"groups": member_raw.groups.map(group_id => track_groups.get(group_id)), "groups": member_raw.groups.map(group_id => track_groups.get(group_id)),
"password": member_raw.password,
}, },
{ {
"silent": true, "password_generated": false,
"signal_change": false,
"greet_member": false,
"notify_admins": false,
} }
); );
} }

View file

@ -18,7 +18,7 @@ namespace _espe.service.group
/** /**
*/ */
export function list( export async function list(
) : Promise< ) : Promise<
Array< Array<
{ {
@ -31,7 +31,12 @@ namespace _espe.service.group
> >
> >
{ {
return _espe.repository.group.list(null); return lib_plankton.list.sorted(
await _espe.repository.group.list(null),
{
"compare_element": (entry1, entry2) => (entry1.preview.label <= entry2.preview.label)
}
);
} }

View file

@ -68,9 +68,9 @@ namespace _espe.service.invitation
"groups_value": groups_value, "groups_value": groups_value,
} : { } : {
name_changeable : boolean; name_changeable : boolean;
name_value : string; name_value : (null | string);
label_changeable : boolean; label_changeable : boolean;
label_value : string; label_value : (null | string);
email_address_changeable : boolean; email_address_changeable : boolean;
email_address_value : (null | string); email_address_value : (null | string);
groups_changeable : boolean; groups_changeable : boolean;
@ -78,15 +78,19 @@ 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;
} = { } = {
} }
) : Promise<{id : _espe.type.invitation_id; key : _espe.type.invitation_key}> ) : Promise<
{
id : _espe.type.invitation_id;
key : _espe.type.invitation_key;
url : (null | string);
}
>
{ {
/** /**
* @todo outsource to conf * @todo outsource to conf
@ -97,7 +101,7 @@ namespace _espe.service.invitation
*/ */
const invitation_key : _espe.type.invitation_key = lib_plankton.sha256.get( const invitation_key : _espe.type.invitation_key = lib_plankton.sha256.get(
( (
name_value (name_value ?? "")
+ +
"/" "/"
+ +
@ -124,6 +128,19 @@ 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)
@ -140,7 +157,7 @@ namespace _espe.service.invitation
(email_address_value !== "") (email_address_value !== "")
) )
&& &&
(notification_target_url_template !== null) (url !== null)
) )
) )
{ {
@ -149,31 +166,29 @@ namespace _espe.service.invitation
{ {
"details": { "details": {
"provided_address": email_address_value, "provided_address": email_address_value,
"notification_target_url_template": notification_target_url_template, "url": url,
}, },
} }
); );
} }
else else
{ {
const url : (null | string) = _espe.helpers.frontend_url_get( try
notification_target_url_template, {
{
"key": invitation_key,
}
);
try {
await _espe.helpers.email_send( await _espe.helpers.email_send(
[email_address_value], [email_address_value],
lib_plankton.translate.get( lib_plankton.string.coin(
"email.invitation.subject", "{{head}} | {{core}}",
{ {
"head": _espe.conf.get().settings.organisation.name,
"core": lib_plankton.translate.get("email.invitation.subject"),
} }
), ),
lib_plankton.translate.get( lib_plankton.translate.get(
"email.invitation.body", "email.invitation.body",
{ {
"url": (url ?? "?"), "url": (url ?? "?"),
"organisation": _espe.conf.get().settings.organisation.name,
} }
), ),
); );
@ -196,10 +211,21 @@ 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(
@ -286,14 +312,15 @@ namespace _espe.service.invitation
} }
else else
{ {
const password : string = ( let password_generated : boolean = (
( (data.password === null)
(data.password !== null) ||
&& (data.password === "")
(data.password !== "") );
) const password_value : string = (
password_generated
? ?
data.password (data.password as string)
: :
_espe.service.member.generate_password() _espe.service.member.generate_password()
); );
@ -302,7 +329,7 @@ namespace _espe.service.invitation
incident : string; incident : string;
details : Record<string, any>; details : Record<string, any>;
} }
> = _espe.service.member.validate_password(password); > = _espe.service.member.validate_password(password_value);
if (flaws_password.length > 0) if (flaws_password.length > 0)
{ {
return ( return (
@ -364,7 +391,13 @@ namespace _espe.service.invitation
?? ??
[] []
), ),
"password": password, "password": password_value,
},
{
"password_generated": password_generated,
"signal_change": true,
"greet_member": true,
"notify_admins": true,
} }
); );

View file

@ -145,18 +145,15 @@ namespace _espe.service.member
*/ */
async function send_activation_email( async function send_activation_email(
member_object : _espe.type.member_object, member_object : _espe.type.member_object,
options : { {
"password": password = null,
} : {
password ?: (null | string); password ?: (null | string);
} = {} } = {}
) : Promise<void> ) : Promise<void>
{ {
options = Object.assign( if (! member_object.enabled)
{ {
"password": null,
},
options
);
if (! member_object.enabled) {
// do nothing // do nothing
} }
else { else {
@ -185,15 +182,17 @@ namespace _espe.service.member
"url": (_espe.conf.get().settings.connections.login_url ?? "--"), "url": (_espe.conf.get().settings.connections.login_url ?? "--"),
"password_info": ( "password_info": (
( (
(options.password === undefined) (password === undefined)
|| ||
(options.password === null) (password === null)
) )
? "" ?
: lib_plankton.string.coin( ""
:
lib_plankton.string.coin(
lib_plankton.translate.get("email.activation.password_info"), lib_plankton.translate.get("email.activation.password_info"),
{ {
"password": options.password, "password": password,
} }
) )
), ),
@ -239,7 +238,12 @@ namespace _espe.service.member
> >
> >
{ {
return _espe.repository.member.list(search_term); return lib_plankton.list.sorted(
await _espe.repository.member.list(search_term),
{
"compare_element": (entry1, entry2) => (entry1.id <= entry2.id)
}
);
} }
@ -255,47 +259,6 @@ namespace _espe.service.member
} }
/**
* legt ein Mitglied an
*/
export async function project(
data : {
name : string;
label : string;
email_address : (null | string);
groups : Array<_espe.type.group_id>;
},
{
"silent": silent = false,
} : {
silent ?: boolean;
} = {
}
) : Promise<_espe.type.member_id>
{
const object : _espe.type.member_object = {
"name": data.name,
"label": data.label,
"email_address": data.email_address,
"groups": data.groups,
"enabled": true,
"password_image": null,
"password_change_last_attempt": null,
"password_change_token": null,
};
const id : _espe.type.member_id = await _espe.repository.member.create(object);
if (silent)
{
// do nothing
}
else
{
signal_change();
}
return id;
}
/** /**
* legt ein Mitglied an * legt ein Mitglied an
*/ */
@ -308,9 +271,15 @@ namespace _espe.service.member
password : string; password : string;
}, },
{ {
"silent": silent = false, "password_generated": password_generated = false,
"signal_change": flag_signal_change = false,
"greet_member": flag_greet_member = false,
"notify_admins": flag_notify_admins = false,
} : { } : {
silent ?: boolean; password_generated ?: boolean;
signal_change ?: boolean;
greet_member ?: boolean;
notify_admins ?: boolean;
} = { } = {
} }
) : Promise<_espe.type.member_id> ) : Promise<_espe.type.member_id>
@ -326,71 +295,60 @@ namespace _espe.service.member
"password_change_token": null, "password_change_token": null,
}; };
const id : _espe.type.member_id = await _espe.repository.member.create(object); const id : _espe.type.member_id = await _espe.repository.member.create(object);
if (silent) // change
{ {
// do nothing if (! flag_signal_change)
} {
else
{
signal_change();
}
return id;
}
/**
* sendet an ein Mitglied eine E-Mail mit Aufforderung zur Registrierung
*/
export async function summon(
member_id : _espe.type.member_id,
url_template : string
) : Promise<(null | string)>
{
_espe.helpers.frontend_url_check();
const member_object : _espe.type.member_object = await get(member_id);
if (member_object.email_address === null)
{
return null;
}
else
{
const url : (null | string) = _espe.helpers.frontend_url_get(
url_template,
{
"verification": await _espe.helpers.verification_get(member_id),
}
);
if (url === null) {
// do nothing // do nothing
} }
else { else
await _espe.helpers.email_send( {
[ signal_change();
member_object.email_address, }
], }
// greet member
{
if (! flag_greet_member)
{
// do nothing
}
else
{
await send_activation_email(
object,
{
"password": (password_generated ? data.password : null),
}
);
}
}
// notify admins
{
if (! flag_notify_admins)
{
// do nothing
}
else
{
_espe.service.admin.notify_all(
lib_plankton.string.coin( lib_plankton.string.coin(
"{{head}} | {{core}}", "{{head}} | {{core}}",
{ {
"head": _espe.conf.get().settings.organisation.name, "head": _espe.conf.get().settings.organisation.name,
"core": lib_plankton.translate.get("email.summon.subject"), "core": lib_plankton.translate.get("email.registration.subject"),
} }
), ),
lib_plankton.string.coin( lib_plankton.string.coin(
lib_plankton.translate.get("email.summon.body"), lib_plankton.translate.get("email.registration.body"),
{ {
"name": name_display(member_object), "name": object.name,
"url": url, "label": object.label,
"remark": (
(_espe.conf.get().settings.summon_email.remark === null)
? ""
: (_espe.conf.get().settings.summon_email.remark + "\n\n")
),
} }
) )
); );
} }
return url;
} }
return id;
} }

View file

@ -235,9 +235,6 @@
"settings": { "settings": {
"organisation": { "organisation": {
"domain": "testdomain.org" "domain": "testdomain.org"
},
"misc": {
"prefix_for_veiled_email_addresses": "wicht-"
} }
} }
}, },

View file

@ -47,6 +47,7 @@ def main():
"--verbose", "--verbose",
"--exclude='conf.json'", "--exclude='conf.json'",
"--exclude='data.sqlite'", "--exclude='data.sqlite'",
"--exclude='log.jsonl'",
("%s/" % args.build_directory), ("%s/" % args.build_directory),
( (
("%s" % args.target_directory) ("%s" % args.target_directory)

View file

@ -74,6 +74,7 @@ ${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 \