Page 1 of 1

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

Posted: Wed Jul 01, 2015 8:43 am
by Shaun Summers

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


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

Posted: Wed Jul 01, 2015 4:58 pm
by Serhii Kulibaba

Hello Shaun,

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


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

Posted: Wed Jul 01, 2015 6:05 pm
by Shaun Summers

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


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

Posted: Thu Jul 02, 2015 8:18 pm
by Shaun Summers

Any news on this?


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

Posted: Thu Jul 02, 2015 9:14 pm
by BananaGator

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


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

Posted: Fri Jul 03, 2015 6:53 am
by Shaun Summers

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


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

Posted: Fri Jul 03, 2015 10:53 am
by BananaGator

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


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

Posted: Wed Jul 08, 2015 1:03 pm
by Shaun Summers

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.


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

Posted: Wed Jul 08, 2015 1:17 pm
by Shaun Summers

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"}}'

------