dj-rest-auth icon indicating copy to clipboard operation
dj-rest-auth copied to clipboard

Passwort reset email template not found.

Open gurumaxi opened this issue 3 years ago • 5 comments

I recently upgraded from version 2.1.4 to version 2.2.2. Everything works fine except my custom passwort reset email template is not found anymore. Instead of this template, the default passwort reset email template is used. The path to the template is correct, as it is detected correctly in version 2.1.4. Here is my CustomPasswordResetSerializer which is registered in settings.py:

from dj_rest_auth.serializers import PasswordResetSerializer

class CustomPasswordResetSerializer(PasswordResetSerializer):
    def get_email_options(self):
        return {
            "html_email_template_name": "registration/password_reset_message.html",
        }

gurumaxi avatar Jan 27 '22 10:01 gurumaxi

It seems that this is causing this misbehaviour:

def password_reset_form_class(self):
        if 'allauth' in settings.INSTALLED_APPS:
            return AllAuthPasswordResetForm
        else:
            return PasswordResetForm

The PasswordResetForm uses your get_email_option, therefore it uses also your template. If you have "allauth" in your installed apps, the AllAuthPasswordResetForm is used, and this won't access your get_email_options function. Here the path to the email template is hardcoded to account/email/password_reset_key.

Not sure if this is a intended behaviour. If yes, what is the alternative to choose a custom path for the template?

MarkNerdi avatar Jan 27 '22 12:01 MarkNerdi

I moved and renamed my html template to account/email/password_reset_key_message.html and I also changed to path in the get_email_options method of my CustomPasswordResetSerializer. The template is now recognized correctly, and an email is sent, but the required uid and token variables which should be passed to the template are not set. Therefore the link is not valid.

gurumaxi avatar Jan 27 '22 12:01 gurumaxi

I've run also into this issue. I downgraded again to 2.1.4.

MarkNerdi avatar Jan 27 '22 13:01 MarkNerdi

I moved and renamed my html template to account/email/password_reset_key_message.html and I also changed to path in the get_email_options method of my CustomPasswordResetSerializer. The template is now recognized correctly, and an email is sent, but the required uid and token variables which should be passed to the template are not set. Therefore the link is not valid.

Hey,

We are facing the same issue, were you able to find a workaround?

tharun634 avatar Oct 16 '22 08:10 tharun634

Downgrading was the only solution for me

MarkNerdi avatar Oct 17 '22 06:10 MarkNerdi