Compare commits
18 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eaf423747 | ||
|
|
0ab67447f3 | ||
|
|
ebc9baa4b3 | ||
|
|
ff75196d26 | ||
|
|
39df56c8af | ||
|
|
1ad4f44793 | ||
|
|
9c6de46702 | ||
|
|
519da08557 | ||
|
|
7f447d3771 | ||
|
|
a51e4504c3 | ||
|
|
d4fdebceca | ||
|
|
05bf22a257 | ||
|
|
a73e11c6f6 | ||
|
|
b522514c26 | ||
|
|
c301789aed | ||
|
|
d3f9a88958 | ||
|
|
eb74ecd66f | ||
|
|
1bd8a9fe36 |
|
|
@ -44,6 +44,14 @@
|
|||
"name": "Example Orginsation",
|
||||
"domain": "example.org"
|
||||
},
|
||||
"misc": {
|
||||
"prefix_for_veiled_email_addresses": "member-",
|
||||
"facultative_membership_number": true,
|
||||
"auto_register": true
|
||||
},
|
||||
"summon_email": {
|
||||
"remark": null
|
||||
},
|
||||
"password_policy": {
|
||||
"minimum_length": 4,
|
||||
"maximum_length": 12,
|
||||
|
|
@ -54,11 +62,13 @@
|
|||
"password_change": {
|
||||
"cooldown_time": 300
|
||||
},
|
||||
"name_index": {
|
||||
"veil": false,
|
||||
"salt": null
|
||||
},
|
||||
"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"
|
||||
"login_url": null
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
|
|
@ -39,24 +39,21 @@
|
|||
"name": "alexandra",
|
||||
"label": "Alexandra Ahorn",
|
||||
"email_address": "alex-rockt@example.org",
|
||||
"groups": [1, 2, 3],
|
||||
"password": "aaa111"
|
||||
"groups": [1, 2, 3]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "berthold",
|
||||
"label": "Berthold Buche",
|
||||
"email_address": "bert-ohne-ernie@example.org",
|
||||
"groups": [4, 5, 2],
|
||||
"password": "bbb222"
|
||||
"groups": [4, 5, 2]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "charlotte",
|
||||
"label": "Charlotte Castania",
|
||||
"email_address": "charly-the-unicorn@example.org",
|
||||
"groups": [4, 1],
|
||||
"password": "ccc333"
|
||||
"groups": [4, 1]
|
||||
}
|
||||
],
|
||||
"invitations": [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Beschreibung
|
||||
|
||||
- Hintergrund-Dienst für [Espe](/espe/meta)
|
||||
- Hintergrund-Dienst für [Espe](https://gitlab.die-linke.cloud/espe/documentation)
|
||||
|
||||
|
||||
## Erstellung
|
||||
|
|
|
|||
|
|
@ -52,34 +52,23 @@ 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,
|
||||
"restriction": () => restriction_logged_in,
|
||||
"execution": () => async ({}) => {
|
||||
const data = await _espe.service.group.list();
|
||||
return Promise.resolve({
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": () => ({
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
124
source/conf.ts
124
source/conf.ts
|
|
@ -149,6 +149,14 @@ namespace _espe.conf
|
|||
name : string;
|
||||
domain : string;
|
||||
};
|
||||
misc : {
|
||||
prefix_for_veiled_email_addresses : string;
|
||||
facultative_membership_number : boolean;
|
||||
auto_register : boolean;
|
||||
};
|
||||
summon_email : {
|
||||
remark : string;
|
||||
};
|
||||
password_policy : {
|
||||
minimum_length : (null | int);
|
||||
maximum_length : (null | int);
|
||||
|
|
@ -159,10 +167,12 @@ namespace _espe.conf
|
|||
password_change : {
|
||||
cooldown_time : int;
|
||||
};
|
||||
name_index : {
|
||||
veil : boolean;
|
||||
salt : (null | string);
|
||||
};
|
||||
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 +220,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 +231,7 @@ namespace _espe.conf
|
|||
"log": (
|
||||
(() => {
|
||||
switch (version) {
|
||||
case 1:
|
||||
{
|
||||
case 1: {
|
||||
return [
|
||||
{
|
||||
"kind": "stdout",
|
||||
|
|
@ -236,9 +245,7 @@ namespace _espe.conf
|
|||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
{
|
||||
case 5: {
|
||||
const node_log = (
|
||||
conf_raw["log"]
|
||||
??
|
||||
|
|
@ -275,15 +282,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 +302,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 +311,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 +330,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 +340,7 @@ namespace _espe.conf
|
|||
};
|
||||
break;
|
||||
}
|
||||
case "redirect":
|
||||
{
|
||||
case "redirect": {
|
||||
return {
|
||||
"kind": kind,
|
||||
"data": {
|
||||
|
|
@ -352,8 +351,7 @@ namespace _espe.conf
|
|||
};
|
||||
break;
|
||||
}
|
||||
case "console":
|
||||
{
|
||||
case "console": {
|
||||
return {
|
||||
"kind": kind,
|
||||
"data": {
|
||||
|
|
@ -361,8 +359,7 @@ namespace _espe.conf
|
|||
};
|
||||
break;
|
||||
}
|
||||
case "drop":
|
||||
{
|
||||
case "drop": {
|
||||
return {
|
||||
"kind": kind,
|
||||
"data": {
|
||||
|
|
@ -370,8 +367,7 @@ namespace _espe.conf
|
|||
};
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
throw (new Error("unhandled"));
|
||||
break;
|
||||
}
|
||||
|
|
@ -391,6 +387,18 @@ namespace _espe.conf
|
|||
"name": ((node_settings["organisation"] ?? {})["name"] ?? "Example Orginsation"), // 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": (
|
||||
((node_settings_password_policy) => ({
|
||||
"minimum_length": (
|
||||
|
|
@ -404,8 +412,8 @@ namespace _espe.conf
|
|||
: 240
|
||||
),
|
||||
"must_contain_letter": (node_settings_password_policy["must_contain_letter"] ?? true),
|
||||
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? false),
|
||||
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? false),
|
||||
"must_contain_number": (node_settings_password_policy["must_contain_number"] ?? true),
|
||||
"must_contain_special_character": (node_settings_password_policy["must_contain_special_character"] ?? true),
|
||||
})) (node_settings["password_policy"] ?? {})
|
||||
),
|
||||
"password_change": (
|
||||
|
|
@ -413,47 +421,15 @@ namespace _espe.conf
|
|||
"cooldown_time": (node_settings_password_change["cooldown_time"] ?? 86400),
|
||||
})) (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": (
|
||||
((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 +438,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 +457,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;}) => {
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
"identifier": "deu"
|
||||
},
|
||||
"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.body": "'{{name}}' ('{{label}}') wurde soeben registriert",
|
||||
"email.registration.body": "Das Mitglied '{{name_display}}' hat sich soeben registriert:\n\n{{url}}",
|
||||
"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.password_info": "Passwort: {{password}}\n\nBitte ändere dein Passwort zeitnah!",
|
||||
|
|
@ -13,7 +15,7 @@
|
|||
"email.password_change.execution.subject": "Passwort-Änderung abgeschlossen",
|
||||
"email.password_change.execution.body": "Hi, {{name}}\n\nDein Passwort wurde soeben geändert.\n",
|
||||
"email.invitation.subject": "Einladung",
|
||||
"email.invitation.body": "Du wurdest zu {{organisation}} eingeladen. Um beizutreten, rufe bitte folgende Adresse auf:\n\n{{url}}",
|
||||
"email.invitation.body": "{{url}}",
|
||||
"help.args.action.description": "auszuführende Aktion; Auswahl",
|
||||
"help.args.action.options.serve": "Server starten",
|
||||
"help.args.action.options.api_doc": "API-Dokumentation gemäß OpenAPI-Spezifikation auf Standard-Ausgabe schreiben",
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
"identifier": "eng"
|
||||
},
|
||||
"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.body": "'{{name}}' ('{{label}}') just has been registered",
|
||||
"email.registration.body": "The member '{{name_display}}' just registered:\n\n{{url}}",
|
||||
"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.password_info": "Password: {{password}}\n\nPlease change your password soon!",
|
||||
|
|
@ -13,7 +15,7 @@
|
|||
"email.password_change.execution.subject": "Password change concluded",
|
||||
"email.password_change.execution.body": "Hi, {{name}}\n\nYour password has just been changed.\n",
|
||||
"email.invitation.subject": "invitation",
|
||||
"email.invitation.body": "You have been invited to {{organisation}}. In order to join, please open the following address:\n\n{{url}}",
|
||||
"email.invitation.body": "{{url}}",
|
||||
"help.args.action.description": "action to executo; options",
|
||||
"help.args.action.options.serve": "start server",
|
||||
"help.args.action.options.api_doc": "write API documentation according to OpenAPI specification to stdout",
|
||||
|
|
|
|||
|
|
@ -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_),
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ namespace _espe.sample
|
|||
label : string;
|
||||
email_address : (null | string);
|
||||
groups : Array<int>;
|
||||
password : string;
|
||||
}
|
||||
>;
|
||||
invitations : Array<
|
||||
|
|
@ -95,19 +94,15 @@ namespace _espe.sample
|
|||
{
|
||||
for (const member_raw of data.members)
|
||||
{
|
||||
const member_id : _espe.type.member_id = await _espe.service.member.add(
|
||||
const member_id : _espe.type.member_id = await _espe.service.member.project(
|
||||
{
|
||||
"name": member_raw.name,
|
||||
"label": member_raw.label,
|
||||
"email_address": member_raw.email_address,
|
||||
"groups": member_raw.groups.map(group_id => track_groups.get(group_id)),
|
||||
"password": member_raw.password,
|
||||
},
|
||||
{
|
||||
"password_generated": false,
|
||||
"signal_change": false,
|
||||
"greet_member": false,
|
||||
"notify_admins": false,
|
||||
"silent": true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace _espe.service.group
|
|||
|
||||
/**
|
||||
*/
|
||||
export async function list(
|
||||
export function list(
|
||||
) : Promise<
|
||||
Array<
|
||||
{
|
||||
|
|
@ -31,12 +31,7 @@ namespace _espe.service.group
|
|||
>
|
||||
>
|
||||
{
|
||||
return lib_plankton.list.sorted(
|
||||
await _espe.repository.group.list(null),
|
||||
{
|
||||
"compare_element": (entry1, entry2) => (entry1.preview.label <= entry2.preview.label)
|
||||
}
|
||||
);
|
||||
return _espe.repository.group.list(null);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ namespace _espe.service.invitation
|
|||
"groups_value": groups_value,
|
||||
} : {
|
||||
name_changeable : boolean;
|
||||
name_value : (null | string);
|
||||
name_value : string;
|
||||
label_changeable : boolean;
|
||||
label_value : (null | string);
|
||||
label_value : string;
|
||||
email_address_changeable : boolean;
|
||||
email_address_value : (null | string);
|
||||
groups_changeable : boolean;
|
||||
|
|
@ -78,19 +78,15 @@ 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;
|
||||
} = {
|
||||
}
|
||||
) : Promise<
|
||||
{
|
||||
id : _espe.type.invitation_id;
|
||||
key : _espe.type.invitation_key;
|
||||
url : (null | string);
|
||||
}
|
||||
>
|
||||
) : Promise<{id : _espe.type.invitation_id; key : _espe.type.invitation_key}>
|
||||
{
|
||||
/**
|
||||
* @todo outsource to conf
|
||||
|
|
@ -101,7 +97,7 @@ namespace _espe.service.invitation
|
|||
*/
|
||||
const invitation_key : _espe.type.invitation_key = lib_plankton.sha256.get(
|
||||
(
|
||||
(name_value ?? "")
|
||||
name_value
|
||||
+
|
||||
"/"
|
||||
+
|
||||
|
|
@ -128,19 +124,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 +140,7 @@ namespace _espe.service.invitation
|
|||
(email_address_value !== "")
|
||||
)
|
||||
&&
|
||||
(url !== null)
|
||||
(notification_target_url_template !== null)
|
||||
)
|
||||
)
|
||||
{
|
||||
|
|
@ -166,29 +149,31 @@ namespace _espe.service.invitation
|
|||
{
|
||||
"details": {
|
||||
"provided_address": email_address_value,
|
||||
"url": url,
|
||||
"notification_target_url_template": notification_target_url_template,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
const url : (null | string) = _espe.helpers.frontend_url_get(
|
||||
notification_target_url_template,
|
||||
{
|
||||
"key": invitation_key,
|
||||
}
|
||||
);
|
||||
try {
|
||||
await _espe.helpers.email_send(
|
||||
[email_address_value],
|
||||
lib_plankton.string.coin(
|
||||
"{{head}} | {{core}}",
|
||||
lib_plankton.translate.get(
|
||||
"email.invitation.subject",
|
||||
{
|
||||
"head": _espe.conf.get().settings.organisation.name,
|
||||
"core": lib_plankton.translate.get("email.invitation.subject"),
|
||||
}
|
||||
),
|
||||
lib_plankton.translate.get(
|
||||
"email.invitation.body",
|
||||
{
|
||||
"url": (url ?? "?"),
|
||||
"organisation": _espe.conf.get().settings.organisation.name,
|
||||
}
|
||||
),
|
||||
);
|
||||
|
|
@ -211,21 +196,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(
|
||||
|
|
@ -312,15 +286,14 @@ namespace _espe.service.invitation
|
|||
}
|
||||
else
|
||||
{
|
||||
let password_generated : boolean = (
|
||||
(data.password === null)
|
||||
||
|
||||
(data.password === "")
|
||||
);
|
||||
const password_value : string = (
|
||||
password_generated
|
||||
const password : string = (
|
||||
(
|
||||
(data.password !== null)
|
||||
&&
|
||||
(data.password !== "")
|
||||
)
|
||||
?
|
||||
(data.password as string)
|
||||
data.password
|
||||
:
|
||||
_espe.service.member.generate_password()
|
||||
);
|
||||
|
|
@ -329,7 +302,7 @@ namespace _espe.service.invitation
|
|||
incident : string;
|
||||
details : Record<string, any>;
|
||||
}
|
||||
> = _espe.service.member.validate_password(password_value);
|
||||
> = _espe.service.member.validate_password(password);
|
||||
if (flaws_password.length > 0)
|
||||
{
|
||||
return (
|
||||
|
|
@ -391,13 +364,7 @@ namespace _espe.service.invitation
|
|||
??
|
||||
[]
|
||||
),
|
||||
"password": password_value,
|
||||
},
|
||||
{
|
||||
"password_generated": password_generated,
|
||||
"signal_change": true,
|
||||
"greet_member": true,
|
||||
"notify_admins": true,
|
||||
"password": password,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -145,15 +145,18 @@ namespace _espe.service.member
|
|||
*/
|
||||
async function send_activation_email(
|
||||
member_object : _espe.type.member_object,
|
||||
{
|
||||
"password": password = null,
|
||||
} : {
|
||||
options : {
|
||||
password ?: (null | string);
|
||||
} = {}
|
||||
) : Promise<void>
|
||||
{
|
||||
if (! member_object.enabled)
|
||||
{
|
||||
options = Object.assign(
|
||||
{
|
||||
"password": null,
|
||||
},
|
||||
options
|
||||
);
|
||||
if (! member_object.enabled) {
|
||||
// do nothing
|
||||
}
|
||||
else {
|
||||
|
|
@ -182,17 +185,15 @@ namespace _espe.service.member
|
|||
"url": (_espe.conf.get().settings.connections.login_url ?? "--"),
|
||||
"password_info": (
|
||||
(
|
||||
(password === undefined)
|
||||
(options.password === undefined)
|
||||
||
|
||||
(password === null)
|
||||
(options.password === null)
|
||||
)
|
||||
?
|
||||
""
|
||||
:
|
||||
lib_plankton.string.coin(
|
||||
? ""
|
||||
: lib_plankton.string.coin(
|
||||
lib_plankton.translate.get("email.activation.password_info"),
|
||||
{
|
||||
"password": password,
|
||||
"password": options.password,
|
||||
}
|
||||
)
|
||||
),
|
||||
|
|
@ -238,12 +239,7 @@ namespace _espe.service.member
|
|||
>
|
||||
>
|
||||
{
|
||||
return lib_plankton.list.sorted(
|
||||
await _espe.repository.member.list(search_term),
|
||||
{
|
||||
"compare_element": (entry1, entry2) => (entry1.id <= entry2.id)
|
||||
}
|
||||
);
|
||||
return _espe.repository.member.list(search_term);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -259,6 +255,47 @@ 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
|
||||
*/
|
||||
|
|
@ -271,15 +308,9 @@ namespace _espe.service.member
|
|||
password : string;
|
||||
},
|
||||
{
|
||||
"password_generated": password_generated = false,
|
||||
"signal_change": flag_signal_change = false,
|
||||
"greet_member": flag_greet_member = false,
|
||||
"notify_admins": flag_notify_admins = false,
|
||||
"silent": silent = false,
|
||||
} : {
|
||||
password_generated ?: boolean;
|
||||
signal_change ?: boolean;
|
||||
greet_member ?: boolean;
|
||||
notify_admins ?: boolean;
|
||||
silent ?: boolean;
|
||||
} = {
|
||||
}
|
||||
) : Promise<_espe.type.member_id>
|
||||
|
|
@ -295,60 +326,71 @@ namespace _espe.service.member
|
|||
"password_change_token": null,
|
||||
};
|
||||
const id : _espe.type.member_id = await _espe.repository.member.create(object);
|
||||
// change
|
||||
if (silent)
|
||||
{
|
||||
if (! flag_signal_change)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
signal_change();
|
||||
}
|
||||
// do nothing
|
||||
}
|
||||
// greet member
|
||||
else
|
||||
{
|
||||
if (! flag_greet_member)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
await send_activation_email(
|
||||
object,
|
||||
{
|
||||
"password": (password_generated ? data.password : null),
|
||||
}
|
||||
);
|
||||
}
|
||||
signal_change();
|
||||
}
|
||||
// notify admins
|
||||
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)
|
||||
{
|
||||
if (! flag_notify_admins)
|
||||
{
|
||||
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
|
||||
}
|
||||
else
|
||||
{
|
||||
_espe.service.admin.notify_all(
|
||||
else {
|
||||
await _espe.helpers.email_send(
|
||||
[
|
||||
member_object.email_address,
|
||||
],
|
||||
lib_plankton.string.coin(
|
||||
"{{head}} | {{core}}",
|
||||
{
|
||||
"head": _espe.conf.get().settings.organisation.name,
|
||||
"core": lib_plankton.translate.get("email.registration.subject"),
|
||||
"core": lib_plankton.translate.get("email.summon.subject"),
|
||||
}
|
||||
),
|
||||
lib_plankton.string.coin(
|
||||
lib_plankton.translate.get("email.registration.body"),
|
||||
lib_plankton.translate.get("email.summon.body"),
|
||||
{
|
||||
"name": object.name,
|
||||
"label": object.label,
|
||||
"name": name_display(member_object),
|
||||
"url": url,
|
||||
"remark": (
|
||||
(_espe.conf.get().settings.summon_email.remark === null)
|
||||
? ""
|
||||
: (_espe.conf.get().settings.summon_email.remark + "\n\n")
|
||||
),
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -235,6 +235,9 @@
|
|||
"settings": {
|
||||
"organisation": {
|
||||
"domain": "testdomain.org"
|
||||
},
|
||||
"misc": {
|
||||
"prefix_for_veiled_email_addresses": "wicht-"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ def main():
|
|||
"--verbose",
|
||||
"--exclude='conf.json'",
|
||||
"--exclude='data.sqlite'",
|
||||
"--exclude='log.jsonl'",
|
||||
("%s/" % args.build_directory),
|
||||
(
|
||||
("%s" % args.target_directory)
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
Loading…
Reference in a new issue