[mod] Bei Annahme der Einladung E-Mails an Mitglied und Admins senden
This commit is contained in:
parent
abd703981f
commit
547c957f42
7 changed files with 101 additions and 77 deletions
|
@ -56,7 +56,7 @@
|
|||
},
|
||||
"connections": {
|
||||
"frontend_url_base": "http://localhost:8888",
|
||||
"login_url": null
|
||||
"login_url": "https://login.example.org"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
|
|
|
@ -39,21 +39,24 @@
|
|||
"name": "alexandra",
|
||||
"label": "Alexandra Ahorn",
|
||||
"email_address": "alex-rockt@example.org",
|
||||
"groups": [1, 2, 3]
|
||||
"groups": [1, 2, 3],
|
||||
"password": "aaa111"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "berthold",
|
||||
"label": "Berthold Buche",
|
||||
"email_address": "bert-ohne-ernie@example.org",
|
||||
"groups": [4, 5, 2]
|
||||
"groups": [4, 5, 2],
|
||||
"password": "bbb222"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "charlotte",
|
||||
"label": "Charlotte Castania",
|
||||
"email_address": "charly-the-unicorn@example.org",
|
||||
"groups": [4, 1]
|
||||
"groups": [4, 1],
|
||||
"password": "ccc333"
|
||||
}
|
||||
],
|
||||
"invitations": [
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
},
|
||||
"tree": {
|
||||
"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.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!",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
},
|
||||
"tree": {
|
||||
"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.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!",
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace _espe.sample
|
|||
label : string;
|
||||
email_address : (null | string);
|
||||
groups : Array<int>;
|
||||
password : string;
|
||||
}
|
||||
>;
|
||||
invitations : Array<
|
||||
|
@ -94,15 +95,19 @@ namespace _espe.sample
|
|||
{
|
||||
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,
|
||||
"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,
|
||||
},
|
||||
{
|
||||
"silent": true,
|
||||
"password_generated": false,
|
||||
"signal_change": false,
|
||||
"greet_member": false,
|
||||
"notify_admins": false,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -295,14 +295,15 @@ namespace _espe.service.invitation
|
|||
}
|
||||
else
|
||||
{
|
||||
const password : string = (
|
||||
(
|
||||
(data.password !== null)
|
||||
&&
|
||||
(data.password !== "")
|
||||
)
|
||||
let password_generated : boolean = (
|
||||
(data.password === null)
|
||||
||
|
||||
(data.password === "")
|
||||
);
|
||||
const password_value : string = (
|
||||
password_generated
|
||||
?
|
||||
data.password
|
||||
(data.password as string)
|
||||
:
|
||||
_espe.service.member.generate_password()
|
||||
);
|
||||
|
@ -311,7 +312,7 @@ namespace _espe.service.invitation
|
|||
incident : string;
|
||||
details : Record<string, any>;
|
||||
}
|
||||
> = _espe.service.member.validate_password(password);
|
||||
> = _espe.service.member.validate_password(password_value);
|
||||
if (flaws_password.length > 0)
|
||||
{
|
||||
return (
|
||||
|
@ -373,7 +374,13 @@ namespace _espe.service.invitation
|
|||
??
|
||||
[]
|
||||
),
|
||||
"password": password,
|
||||
"password": password_value,
|
||||
},
|
||||
{
|
||||
"password_generated": password_generated,
|
||||
"signal_change": true,
|
||||
"greet_member": true,
|
||||
"notify_admins": true,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -145,18 +145,15 @@ namespace _espe.service.member
|
|||
*/
|
||||
async function send_activation_email(
|
||||
member_object : _espe.type.member_object,
|
||||
options : {
|
||||
{
|
||||
"password": password = null,
|
||||
} : {
|
||||
password ?: (null | string);
|
||||
} = {}
|
||||
) : Promise<void>
|
||||
{
|
||||
options = Object.assign(
|
||||
if (! member_object.enabled)
|
||||
{
|
||||
"password": null,
|
||||
},
|
||||
options
|
||||
);
|
||||
if (! member_object.enabled) {
|
||||
// do nothing
|
||||
}
|
||||
else {
|
||||
|
@ -185,15 +182,17 @@ namespace _espe.service.member
|
|||
"url": (_espe.conf.get().settings.connections.login_url ?? "--"),
|
||||
"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"),
|
||||
{
|
||||
"password": options.password,
|
||||
"password": password,
|
||||
}
|
||||
)
|
||||
),
|
||||
|
@ -260,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
|
||||
*/
|
||||
|
@ -313,9 +271,15 @@ namespace _espe.service.member
|
|||
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>
|
||||
|
@ -331,7 +295,9 @@ namespace _espe.service.member
|
|||
"password_change_token": null,
|
||||
};
|
||||
const id : _espe.type.member_id = await _espe.repository.member.create(object);
|
||||
if (silent)
|
||||
// change
|
||||
{
|
||||
if (! flag_signal_change)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -339,6 +305,49 @@ namespace _espe.service.member
|
|||
{
|
||||
signal_change();
|
||||
}
|
||||
}
|
||||
// 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(
|
||||
"{{head}} | {{core}}",
|
||||
{
|
||||
"head": _espe.conf.get().settings.organisation.name,
|
||||
"core": lib_plankton.translate.get("email.registration.subject"),
|
||||
}
|
||||
),
|
||||
lib_plankton.string.coin(
|
||||
lib_plankton.translate.get("email.registration.body"),
|
||||
{
|
||||
"name": object.name,
|
||||
"label": object.label,
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue