Page 1 of 2

Using email as username - problems with Password Recovery tutorial

Posted: Sat Dec 20, 2014 3:46 pm
by Thomas Anderson7286790

I have created an app that writes the user's email into the username field in my user's database. No issues there... However, when I built password recovery features into my app based on this tutorial:

http://devcenter.appery.io/tutorials/...

I cannot get my service request to find the user when sending an email address as the value for 'username'.

I get the following response:

{
"message":"User not found"
}

When I create a username in the database that is a non-email string (i.e. "johndoe"), and re-test the service, the user is identified and the recovery code is sent out by email via SendGrid as intended.

Any ideas?


Using email as username - problems with Password Recovery tutorial

Posted: Sat Dec 20, 2014 6:25 pm
by Alena Prykhodko

Hello,

Please show a screenshot of the mapping and service settings.


Using email as username - problems with Password Recovery tutorial

Posted: Sat Dec 20, 2014 7:17 pm
by Thomas Anderson7286790

Haven't set up the mapping yet. I'm using the test feature in the service settings.


Using email as username - problems with Password Recovery tutorial

Posted: Mon Dec 22, 2014 12:23 am
by Yurii Orishchuk

Hi Thomas,

Please use following line of JS code in where clause:

pre

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

/pre

So the username should be urlEncoded.

Regards.


Using email as username - problems with Password Recovery tutorial

Posted: Mon Dec 22, 2014 3:29 am
by Thomas Anderson7286790

Did you mean

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

instead of

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

encodeURI appears to work!

Regards,

Thomas


Using email as username - problems with Password Recovery tutorial

Posted: Mon Dec 22, 2014 5:55 am
by Yurii Orishchuk

Hi Thomas,

Yes... Glad it works.

Regards.


Using email as username - problems with Password Recovery tutorial

Posted: Sun Feb 01, 2015 10:42 am
by Vinny B

Hello

Code: Select all

I have the same problem but I do not know where to put the above code. I do not have a where field. I am mapping to a username field like the tutorial says. If i past your code into the js in mapping I get a error with the code.  

I need to use a email as a username.

Thank You
Vinny


Using email as username - problems with Password Recovery tutorial

Posted: Sun Feb 01, 2015 12:27 pm
by M&M

Add a request parameter for the service by the name of "where"

Image


Using email as username - problems with Password Recovery tutorial

Posted: Mon Feb 02, 2015 7:07 am
by Evgene Karachevtsev

Hello!

1) Please add a database service called query
2) Open it and you will see where parameter
or
1) open a database collection
2) click on FIND button
3) create service with all the settings for this request type
4) add where parameter manually (click add in the request tab of a service)


Using email as username - problems with Password Recovery tutorial

Posted: Mon Feb 02, 2015 1:05 pm
by Vinny B

The database service works fine with a username that is not an e-mail.

example vinny

The database service does not work if I use and e-mail

example a href="mailto:vinny20@gmail.com" rel="nofollow"vinny20@gmail.com/a

The server side script works fine if I use an e-mail directly in the code

I tried the where parameter and yuri code but It does not work.

Here is my where ( iam mapping from username to where)
Image

here is my console

Image

Any ideas?