SMS - Two Factor Authentication OTP MSG Change

Hello Everyone,

I’ve been testing ERPNext and trying to secure it.
I’ve been successfully able to setup the SMS settings, and I’ve been able to send SMS through ERPNext. As a next step, I’ve been trying to setup the Two Factor Authentication (SMS) in ERPNext. The only issue I’m facing is that I can see my SMS Gateway Receiving the command, but the sending fails. After performing a lot of investigation, I have discovered that All our Mobile Networks in our Country block the following SMS String:

Your verification code is XXXXXX

So I was wondering, If I wanted to customize and change the SMS OTP Text from this to something else, how can I do it?

ex. Your Login Code is XXXXXX

Your help will be much appreciated.
Thanks in advance.

Best Regards,
SherifM

I can’t guarentee that it’s the best place to make those adjustments. but if you run this command from the frappe-bench folder it tells you the name of the files that contain that string

find . -name ‘*.py’ | xargs grep 'Your verification code is ’

running that on my system returns
apps/frappe/frappe/twofactor.py
and
apps/frappe/frappe/core/doctype/user/user.py

my bet is on twofactor.py

1 Like

Hello @mattlongfield,

Thanks for your help.
I did exactly as you mentioned.

The only difference is that I got permission denied so I used the exact same command except I added “sudo” at the beginning.

sudo find . -name ‘*.py’ | xargs grep 'Your verification code is ’

I got the same files as the ones you got. I went on and changed the “twofactor.py” file and saved it.

when I tried logging in, it didn’t change the verification SMS text accordingly.
So I decided to restart the server before attempting to change the other file by running the following command:

sudo reboot now

Once the restart has been complete, I got the SMS message adjusted accordingly, and now I’m getting:

Your Login code is XXXXXX

So as you said, there is no need to change the user.py file.

Again, thanks for your help.

1 Like