diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..178ae1513 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [BeryJu] diff --git a/passbook/stages/email/api.py b/passbook/stages/email/api.py index 063a1020e..22dc15ca9 100644 --- a/passbook/stages/email/api.py +++ b/passbook/stages/email/api.py @@ -22,6 +22,9 @@ class EmailStageSerializer(ModelSerializer): "use_ssl", "timeout", "from_address", + "token_expiry", + "subject", + "template", ] extra_kwargs = {"password": {"write_only": True}} diff --git a/passbook/stages/email/forms.py b/passbook/stages/email/forms.py index bdd865fb1..e158743e1 100644 --- a/passbook/stages/email/forms.py +++ b/passbook/stages/email/forms.py @@ -27,6 +27,9 @@ class EmailStageForm(forms.ModelForm): "use_ssl", "timeout", "from_address", + "token_expiry", + "subject", + "template", ] widgets = { "name": forms.TextInput(), diff --git a/passbook/stages/email/migrations/0003_auto_20200515_1242.py b/passbook/stages/email/migrations/0003_auto_20200515_1242.py new file mode 100644 index 000000000..aef2c65d9 --- /dev/null +++ b/passbook/stages/email/migrations/0003_auto_20200515_1242.py @@ -0,0 +1,32 @@ +# Generated by Django 3.0.5 on 2020-05-15 12:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("passbook_stages_email", "0002_auto_20200510_1844"), + ] + + operations = [ + migrations.AddField( + model_name="emailstage", + name="subject", + field=models.TextField(default="passbook"), + ), + migrations.AddField( + model_name="emailstage", + name="template", + field=models.TextField( + choices=[ + ("stages/email/for_email/password_reset.html", "Password Reset"), + ( + "stages/email/for_email/account_confirmation.html", + "Account Confirmation", + ), + ], + default="stages/email/for_email/password_reset.html", + ), + ), + ] diff --git a/passbook/stages/email/models.py b/passbook/stages/email/models.py index c5ec2e9e5..4eef283df 100644 --- a/passbook/stages/email/models.py +++ b/passbook/stages/email/models.py @@ -7,6 +7,19 @@ from django.utils.translation import gettext as _ from passbook.flows.models import Stage +class EmailTemplates(models.TextChoices): + """Templates used for rendering the E-Mail""" + + PASSWORD_RESET = ( + "stages/email/for_email/password_reset.html", + _("Password Reset"), + ) # nosec + ACCOUNT_CONFIRM = ( + "stages/email/for_email/account_confirmation.html", + _("Account Confirmation"), + ) + + class EmailStage(Stage): """email stage""" @@ -17,12 +30,15 @@ class EmailStage(Stage): use_tls = models.BooleanField(default=False) use_ssl = models.BooleanField(default=False) timeout = models.IntegerField(default=10) + from_address = models.EmailField(default="system@passbook.local") token_expiry = models.IntegerField( default=30, help_text=_("Time in minutes the token sent is valid.") ) - - from_address = models.EmailField(default="system@passbook.local") + subject = models.TextField(default="passbook") + template = models.TextField( + choices=EmailTemplates.choices, default=EmailTemplates.PASSWORD_RESET + ) type = "passbook.stages.email.stage.EmailStageView" form = "passbook.stages.email.forms.EmailStageForm" diff --git a/passbook/stages/email/stage.py b/passbook/stages/email/stage.py index 0bb49e5b3..a1271ab18 100644 --- a/passbook/stages/email/stage.py +++ b/passbook/stages/email/stage.py @@ -54,7 +54,7 @@ class EmailStageView(FormView, AuthenticationStage): # Send mail to user message = TemplateEmailMessage( subject=_("passbook - Password Recovery"), - template_name="stages/email/for_email/password_reset.html", + template_name=self.executor.current_stage.template, to=[pending_user.email], template_context={ "url": self.get_full_url(**{QS_KEY_TOKEN: nonce.pk.hex}), diff --git a/passbook/stages/email/templates/stages/email/for_email/account_confirm.html b/passbook/stages/email/templates/stages/email/for_email/account_confirm.html index 5a4488162..f300b6585 100644 --- a/passbook/stages/email/templates/stages/email/for_email/account_confirm.html +++ b/passbook/stages/email/templates/stages/email/for_email/account_confirm.html @@ -3,82 +3,36 @@ {% load inline %} {% load i18n %} -{% block pre_header %} -{% trans "We're thrilled to have you here! Get ready to dive into your new account." %} -{% endblock %} - {% block content %} - -
- {% trans 'Welcome!' %} -- |
-
- - {% trans "We're excited to have you get started. First, you need to confirm your account. Just press the button below."%} - - |
- ||
-
|
- ||
- - {% trans "If that doesn't work, copy and paste the following link in your browser:" %} - |
- ||
- - | -||
- - {% trans "If you have any questions, just reply to this email—we're always happy to help out." %} - - |
-
+ {% trans "We're excited to have you get started. First, you need to confirm your account. Just press the button below."%} +
+
+
|
+
+ {% blocktrans with url=url %} + If that doesn't work, copy and paste the following link in your browser: {{ url }} + {% endblocktrans %} +
++ {% trans "If you have any questions, just reply to this email—we're always happy to help out." %} +
+