Opened 3 years ago

Closed 3 years ago

#32401 closed Bug (needsinfo)

Email template for resetting password is missing the port the application is running on

Reported by: Bergiu Owned by: nobody
Component: contrib.admin Version: 3.1
Severity: Normal Keywords: email template reset
Cc: Florian Apolloner Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If the django application is running on a different port than 80 or 443 the email template for resetting the password sends the wrong link for the confirmation.

I have installed dj-rest-auth and allauth. There are methods to reset the password of an account. These methods use django.contrib.auth.forms.PasswordResetForm and this sends an email to the given email address with the template from django/contrib/admin/templates/registration/password_reset_email.html. There is no option in this template to set the port in the confirm address.

For now i use a hack, where i put the port in the sites domain name, but i think, there should be an option to set the port in this template:
https://github.com/django/django/blob/master/django/contrib/admin/templates/registration/password_reset_email.html#L6

Change History (1)

comment:1 by Mariusz Felisiak, 3 years ago

Cc: Florian Apolloner added
Resolution: needsinfo
Status: newclosed

For now i use a hack, where i put the port in the sites domain name, but i think, there should be an option to set the port in this template

That is not a hack, see the get_current_site() docs. Site.domain should contain the port if django.contrib.sites is installed and the current Site is set. If not, a RequestSite object based on the request is returned.

Maybe your Web server isn't setting the SERVER_PORT header appropriately? or, if you're using HTTP_X_FORWARDED_PORT, it's a duplicate of #31354.

Note: See TracTickets for help on using tickets.
Back to Top