Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

Password reset doesn't work is login is email address.

Hello,

I followed this tutorial to set up password recovery:

https://devcenter.appery.io/tutorials...

It works perfectly except when a user has used their email address as their Login. When the Login is an email address and they click 'Get Secret Code' they get a message saying that the user does not exist.

Any suggestions?

Shaun

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Password reset doesn't work is login is email address.

Hello Shaun,

Do you use the same values for email and name fields? Could you send us screenshot with DB structure?

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

Password reset doesn't work is login is email address.

Hi,

No I don't use the same values. Attached is a screen shot of the users database structure. I've highlighted the one that is causing problems.

Shaun
Image

BananaGator
Posts: 0
Joined: Tue Jun 30, 2015 2:53 am

Password reset doesn't work is login is email address.

Check the filtering that your service JavaScripts are using. If you aren't sure about it being correct, paste what you have so far.

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

Password reset doesn't work is login is email address.

Hi,

Thanks for your reply. There is no javascript filters. Just a couple of javascript alerts. What I have is exactly what is described in the tutorial.

Regards, Shaun

BananaGator
Posts: 0
Joined: Tue Jun 30, 2015 2:53 am

Password reset doesn't work is login is email address.

In your recovery script, you can attempt to debug, then.

Somewhere around line 26, add an alert to see what is being sent through the "username" filter. You can also set console logs for the paramKeys.

The most simple method (to start) would probably be to remove the encoding function that's around the username variable.

Image

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

Password reset doesn't work is login is email address.

I have found what BananaGator was refering to (thanks!)

I also found a previous question (https://getsatisfaction.com/apperyio/...) on this which was answered by Appery and fixed the issue.

However, the WHERE... from that question and the WHERE code in the file I'm looking at is not the same and the fix proposed no longer works.

Today's WHERE:

"where": '{"username": "' + encodeURIComponent(username) + '"}'

-------

Can anybody help me modify this code so that it will look up usernames with special characters (in particular the @ symbol) in the database. It currently returns a message saying that these users do not exist.

Regards, Shaun.

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

Password reset doesn't work is login is email address.

My bad! Just worked it out.

You need to replace this line in two places. In the server code file ResetPassword AND in the server code file SendEmail. SendEmail is the code that runs when you request a secret code. ResetPassword then runs when you choose a new password (and it picks up the username from the first field.)

The code provided by Appery therefore works:

"where": '{"username": {"$regex": "^' + username + '$", "$options":"i"}}'

------

Return to “Issues”