diff --git a/.env.example b/.env.example index 436b34ff..4bfdc644 100644 --- a/.env.example +++ b/.env.example @@ -18,3 +18,4 @@ EMAIL_HOST_USER='' EMAIL_HOST_PASSWORD='' EMAIL_BACKEND_CONSOLE='True/False' EMAIL_USE_TLS=True +DEFAULT_FROM_EMAIL='your-email@example.com' diff --git a/app/accounts/forms.py b/app/accounts/forms.py index a86ed2f2..d2904474 100644 --- a/app/accounts/forms.py +++ b/app/accounts/forms.py @@ -5,7 +5,6 @@ PasswordResetForm, UserCreationForm, ) -from django.contrib.auth.models import User from django.utils.translation import gettext_lazy as _ from users.models import CustomUser @@ -48,11 +47,9 @@ def __init__(self, *args, **kwargs): field.widget.attrs.update({"class": "form-control"}) -User = get_user_model() - - class CustomPasswordResetForm(PasswordResetForm): def clean_email(self): + User = get_user_model() email = self.cleaned_data["email"] users = User.objects.filter(email=email) if not users.exists(): diff --git a/app/accounts/views.py b/app/accounts/views.py index f6d65275..e07c81fe 100644 --- a/app/accounts/views.py +++ b/app/accounts/views.py @@ -96,3 +96,4 @@ class CustomPasswordResetView(PasswordResetView): form_class = CustomPasswordResetForm template_name = "accounts/password_reset_form.html" success_url = "/accounts/password_reset/done/" + html_email_template_name = "registration/password_reset_email.html" diff --git a/app/templates/registration/password_reset_email.html b/app/templates/registration/password_reset_email.html index d566b1db..88bafad8 100644 --- a/app/templates/registration/password_reset_email.html +++ b/app/templates/registration/password_reset_email.html @@ -1,6 +1,7 @@ - + + Password Reset
-
-

Password Reset

-
-
-

Hello {{ user.get_username }},

-

You requested a password reset. Click the button below to reset your password:

-

- Reset - my password -

-

If you didn't request this, please ignore this email.

-

Thanks,

-

Your website team

-
- +

Password Reset

+ +

Hello {{ user.get_username }},

+

You requested a password reset. Click the button below to reset your password:

+

+ + Reset my password + +

+

If you didn't request this, please ignore this email.

+

Thanks,

+

Your website team

- \ No newline at end of file +