plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
246 stars 186 forks source link

The mail sent to reset the password doesn't contain the IP address from which the request was made #2949

Closed dbitouze closed 4 years ago

dbitouze commented 5 years ago

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

What I did:

Create a Plone 5 site, add a user and test the password reset.

What I expect to happen:

The mail sent should contain an IP address at the end of the sentence "Request made from IP address"

What actually happened:

The mail sent doesn't contain the IP address at the end of the sentence "Request made from IP address": it looks like the variable ${ipaddress} gives nothing.

What version of Plone/ Addons I am using:

tkimnguyen commented 5 years ago

Denis, what was the URL of the website?

dbitouze commented 5 years ago

Hi Kim. It was a local URL: http://localhost:8083/Plone/

vincentfretin commented 4 years ago

Products/CMFPlone/browser/login/templates/mail_password_template.pt uses


<tal:i18n                                                                       
     i18n:translate="mailtemplate_tracking_information"                         
     tal:condition="isAnon">                                                    
If you didn't expect to receive this email, please ignore it. Your password has not been changed.
Request made from IP address <tal:i18n tal:define="host request/HTTP_X_FORWARDED_FOR|request/REMOTE_ADDR"
          tal:content="host"                                                    
          i18n:name="ipaddress" />                                              
</tal:i18n>

So it uses HTTP_X_FORWARDED_FOR (you should have it behind apache or nginx) or fallback to REMOTE_ADDR if request/HTTP_X_FORWARDED_FOR gives an exception. This probably never happen? Can you try something like this?

<tal:i18n tal:define="host python:request.HTTP_X_FORWARDED_FOR or request.REMOTE_ADDR"
vincentfretin commented 4 years ago

Did you test my suggestion @dbitouze ?

vincentfretin commented 4 years ago

I tested, what I said fix the issue. I have now 127.0.0.1 locally.

dbitouze commented 4 years ago

@vincentfretin Sorry for not having tested your suggestion. No time for this right now but if you noticed the issue and afterwards fixed it, I guess we can close this issue :)