Forgot Password Service
Hi, could you give us your public app link?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Hi, could you give us your public app link?
Do you call any script in scRecoverCode service? What is the code there?
I call server code.
Hi Doug,
Please share your app, database and server code with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a
Done, done, and done!
Hi Doug,
This may take some time. Working on it.
Hi Doug,
As I can see you implement nothing in server code. I would advice you to create 2 server scripts: for sending mail and for changing password.
1) Here is the script to send email. Only email entered by user for restoring password is sent to this script, all the other data (database id etc) should be stored in script itself.
prevar responseBody = {},
requestParams = {},
paramKeys = request.keys();
for (var key = 0; key < paramKeys.length; key++) {
requestParams[paramKeys[key]] = request.get(paramKeys[key]);
}
var email = requestParams['email'];
var randomString = Math.random().toString(36).slice(-12);
//
//here is your "update User collection" code. Update User collection for user with E-mail == 'email' (set secret_code = 'randomString')
//this should help http://docs.appery.io/documentation/backendservices/server-code/#Database_API
//
//here is your "send E-mail" code. Send E-mail (for example via SendGrid) to 'email' with randomString
//this should help http://docs.appery.io/documentation/backendservices/server-code/#XMLHttpRequest
//
responseBody.message = "success"
response.success(responseBody, "application/json");/pre
2) Here is the script to reset your password. The code received in mail, email and new password are sent to this script:
prevar responseBody = {},
requestParams = {},
paramKeys = request.keys();
for (var key = 0; key < paramKeys.length; key++) {
requestParams[paramKeys[key]] = request.get(paramKeys[key]);
}
var email = requestParams['email'];
var newPass = requestParams['newPass'];
var code = requestParams['code'];
var allCorrect = false;
//
//here is your "check User collection" code. Check is there user with E-mail == 'email' && secret_code = 'code'
//this should help http://docs.appery.io/documentation/backendservices/server-code/#Database_API
//set allCorrect = true if user was found
if (allCorrect) {
//here is your "Update User collection" code. Set new password.
//this should help http://docs.appery.io/documentation/backendservices/server-code/#Database_API
//
responseBody.message = "success"
} else {
responseBody.message = "some error"
}
response.success(responseBody, "application/json");/pre
Thanks, I'll get to work! Appreciate all of your help on this!
Hi Doug
Did you come right with this issue?
Thx