diff --git a/canaille/account.py b/canaille/account.py index b7f73a6d..99a2ec69 100644 --- a/canaille/account.py +++ b/canaille/account.py @@ -155,9 +155,11 @@ def users(user): def user_invitation(user): form = InvitationForm(request.form or None) - success = False + mail_sent = None registration_url = None + form_validated = False if request.form and form.validate(): + form_validated = True registration_url = url_for( "account.registration", data=obj_to_b64([form.uid.data, form.mail.data, form.groups.data]), @@ -165,15 +167,14 @@ def user_invitation(user): _external=True, ) - success = send_invitation_mail(form.mail.data, registration_url) - if not success: - flash(_("An error happened whilen sending the invitation link."), "error") + mail_sent = send_invitation_mail(form.mail.data, registration_url) return render_template( "invite.html", form=form, menuitems="users", - success=success, + form_validated=form_validated, + mail_sent=mail_sent, registration_url=registration_url, ) diff --git a/canaille/templates/invite.html b/canaille/templates/invite.html index b44ffa72..df1481b6 100644 --- a/canaille/templates/invite.html +++ b/canaille/templates/invite.html @@ -7,22 +7,37 @@ {% block content %}
- {% if success %} + {% if form_validated %}

- {{ _("Invitation sent") }} + {% if mail_sent %} + {{ _("Invitation sent") }} + {% else %} + {{ _("Invitation not sent") }} + {% endif %}

+ {% if mail_sent %}
{% set email = form.mail.data %} - {% trans %}This invitation link has been to {{ email }}{% endtrans %} + {% trans %}This invitation link has been sent to {{ email }}{% endtrans %} {% trans %}If you need to provide this link by other ways than email, you can copy it there:{% endtrans %}
+ {% else %} + +
+ {% set email = form.mail.data %} + {% trans %}This invitation link could not be sent to {{ email }} due to technical issues.{% endtrans %} + {% trans %}However you can copy the there to provide it by other ways than email:{% endtrans %} +
+ {% endif %} + +
@@ -39,9 +54,11 @@ {{ _("Create a user") }} + {% if mail_sent %} {{ _("Invite another user") }} + {% endif %}