Email links with wrong server address

I have modified the email template files for new user creation [1] and resetting the password [2].
[1] /home/frappe/frappe-bench/apps/frappe/frappe/templates/emails/new_user.html
[2] /home/frappe/frappe-bench/apps/frappe/frappe/templates/emails/password_reset.html

However the final output should be modified even further, specially the lines with link to complete registration/password reset.
[1] a href="{{ link }}">{{ (“Complete Registration”) }}
[2] a href="{{ link }}">Reset your password

Now the link points to a server in local network (192.168.x.x) and when users click the link, for example at home, they can’t complete the process.
I’ve tried to use the automatically generated token
/update-password?key=xXyYzZ1xXyYzZ2etc
with the public address and it works. Though most of the users won’t be satisfied with a broken link (even if it would be possible to hack the right result out of it)

Where do I find the controller code responsible for sending the emails so I could change some details and fork it to use the static (and public) name.

Piecing together the puzzle, these are notes to self -

Is this the controller?

For eg this method send_login_mail

General notes on https://frappe.io/docs/user/en/tutorial/controllers

I tried this search
frappe@erpnext:~/frappe-bench$ find . -name ‘*.py’ | xargs grep “reset_password”

that turned up this:
./apps/frappe/frappe/core/doctype/user/user.py

that turned up this

frappe@erpnext:~/frappe-bench$ find . -name ‘*.py’ | xargs grep “validate_reset_password”
./apps/erpnext_demo/erpnext_demo/hooks.py: “validate_reset_password”: “erpnext_demo.utils.validate_reset_password”
./apps/erpnext_demo/erpnext_demo/utils.py:def validate_reset_password(doc, method):
./apps/frappe/frappe/core/doctype/user/user.py: def validate_reset_password(self):
./apps/frappe/frappe/core/doctype/user/user.py: user.validate_reset_password()

Or put a deliberate exception to generate a stack trace

https://codereview.stackexchange.com/questions/80730/failing-fast-by-raising-an-exception-with-a-custom-message

hope this helps!

Isn’t static name controlled by site_config.json using Host_name setting?

I believe so … easier than expected

1 Like

Thought so. I am not a developer and the previous post was too intimidating for me to follow up with my simplistic answer.

Thanks H_N & Julian

Actually I can’t say I grasp this piece of the puzzle you two have added, thanks!

clarkej,

Since you asked. Site_config.json resides in each site’s directory. To define static name, just add the following line:

“host_name”:“http://public name or ip”;. in site_config.json file.

Hope that clears up the puzzle.

Cheers.

2 Likes

Ah yes this block of ip addresses 192.168.x.x is reserved for private networks