From b5779a1642c3b27bccbe2b655249459fb72829ce Mon Sep 17 00:00:00 2001 From: hashlash <muh.ashlah@gmail.com> Date: Wed, 4 Nov 2020 15:39:19 +0700 Subject: [PATCH] add custom activation and password reset email template --- requirements.txt | 2 +- sizakat/settings.py | 18 ++++++++++++++---- sizakat/templates/email/activation_email.html | 7 +++++++ sizakat/templates/email/activation_subject.txt | 1 + .../templates/email/password_reset_email.html | 7 +++++++ .../templates/email/password_reset_subject.txt | 1 + 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 sizakat/templates/email/activation_email.html create mode 100644 sizakat/templates/email/activation_subject.txt create mode 100644 sizakat/templates/email/password_reset_email.html create mode 100644 sizakat/templates/email/password_reset_subject.txt diff --git a/requirements.txt b/requirements.txt index 703b030..1809097 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ coverage==5.2.1 Django==3.0.7 django-cors-headers==3.4.0 django-filter==2.3.0 -django-graphql-auth==0.3.11 +django-graphql-auth==0.3.14 django-graphql-jwt==0.3.1 freezegun==1.0.0 graphene-django==2.10.1 diff --git a/sizakat/settings.py b/sizakat/settings.py index cd1d75e..54484a9 100644 --- a/sizakat/settings.py +++ b/sizakat/settings.py @@ -15,7 +15,6 @@ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ @@ -27,6 +26,8 @@ DEBUG = os.environ.get("DEBUG", False) ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS').split() +FRONTEND_BASE_URL = os.environ.get('FRONTEND_BASE_URL', 'http://localhost:3000') + # Application definition @@ -58,15 +59,14 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -CORS_ORIGIN_WHITELIST = os.environ.get( - 'CORS_ORIGIN_WHITELIST', 'http://localhost:3000').split() +CORS_ORIGIN_WHITELIST = os.environ.get('CORS_ORIGIN_WHITELIST', FRONTEND_BASE_URL).split() ROOT_URLCONF = 'sizakat.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, "templates")], + 'DIRS': [os.path.join(BASE_DIR, 'sizakat', 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -202,3 +202,13 @@ GRAPHQL_JWT = { 'JWT_VERIFY_EXPIRATION': True, 'JWT_LONG_RUNNING_REFRESH_TOKEN': True, } + + +# Django GraphQL Auth +# https://django-graphql-auth.readthedocs.io/en/latest/settings/ + +GRAPHQL_AUTH = { + 'EMAIL_TEMPLATE_VARIABLES': { + 'frontend_base_url': FRONTEND_BASE_URL, + } +} diff --git a/sizakat/templates/email/activation_email.html b/sizakat/templates/email/activation_email.html new file mode 100644 index 0000000..518f359 --- /dev/null +++ b/sizakat/templates/email/activation_email.html @@ -0,0 +1,7 @@ +<p>Assalamu'alaikum warrahmatullah wabarakatuh.</p> + +<p>Bapak/Ibu dapat mengaktifkan akun {{ user.username }} di Aplikasi SIZAKAT dengan klik link berikut:</p> + +<p>{{ frontend_base_url }}/{{ path }}/{{ token }}.</p> + +<p>Jazaakumullahu Khoiron.</p> diff --git a/sizakat/templates/email/activation_subject.txt b/sizakat/templates/email/activation_subject.txt new file mode 100644 index 0000000..56cb27f --- /dev/null +++ b/sizakat/templates/email/activation_subject.txt @@ -0,0 +1 @@ +[PENGAKTIFKAN AKUN SIZAKAT] diff --git a/sizakat/templates/email/password_reset_email.html b/sizakat/templates/email/password_reset_email.html new file mode 100644 index 0000000..900eca0 --- /dev/null +++ b/sizakat/templates/email/password_reset_email.html @@ -0,0 +1,7 @@ +<p>Assalamu'alaikum warrahmatullah wabarakatuh.</p> + +<p>Bapak/Ibu dapat membuat ulang password untuk akun {{ user.username }} di Aplikasi SIZAKAT dengan klik link berikut:</p> + +<p>{{ frontend_base_url }}/{{ path }}/{{ token }}</p> + +<p>Jazaakumullahu Khoiron.</p> diff --git a/sizakat/templates/email/password_reset_subject.txt b/sizakat/templates/email/password_reset_subject.txt new file mode 100644 index 0000000..f7e7ffd --- /dev/null +++ b/sizakat/templates/email/password_reset_subject.txt @@ -0,0 +1 @@ +[RESET PASSWORD SIZAKAT] -- GitLab