Page 2 of 6

Forgot Password Service

Posted: Tue Sep 24, 2013 10:27 am
by Maryna Brodina

Hi, could you give us your public app link?


Forgot Password Service

Posted: Tue Sep 24, 2013 11:38 am
by Doug Black

Forgot Password Service

Posted: Tue Sep 24, 2013 1:07 pm
by Maryna Brodina

Do you call any script in scRecoverCode service? What is the code there?


Forgot Password Service

Posted: Tue Sep 24, 2013 1:17 pm
by Doug Black

Forgot Password Service

Posted: Tue Sep 24, 2013 2:46 pm
by Kateryna Grynko

Hi Doug,

Please share your app, database and server code with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a


Forgot Password Service

Posted: Tue Sep 24, 2013 2:58 pm
by Doug Black

Done, done, and done!


Forgot Password Service

Posted: Tue Sep 24, 2013 9:11 pm
by Kateryna Grynko

Hi Doug,

This may take some time. Working on it.


Forgot Password Service

Posted: Wed Sep 25, 2013 4:03 pm
by Kateryna Grynko

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&#46;length; key++) {
requestParams[paramKeys[key]] = request&#46;get(paramKeys[key]);
}
var email = requestParams['email'];
var randomString = Math&#46;random()&#46;toString(36)&#46;slice(-12);
&#47;&#47;
&#47;&#47;here is your "update User collection" code&#46; Update User collection for user with E-mail == 'email' (set secret_code = 'randomString')
&#47;&#47;this should help http:&#47;&#47;docs&#46;appery&#46;io&#47;documentation&#47;backendservices&#47;server-code&#47;#Database_API
&#47;&#47;
&#47;&#47;here is your "send E-mail" code&#46; Send E-mail (for example via SendGrid) to 'email' with randomString
&#47;&#47;this should help http:&#47;&#47;docs&#46;appery&#46;io&#47;documentation&#47;backendservices&#47;server-code&#47;#XMLHttpRequest
&#47;&#47;
responseBody&#46;message = "success&quot
response&#46;success(responseBody, "application&#47;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&#46;keys();
for (var key = 0; key < paramKeys&#46;length; key++) {
requestParams[paramKeys[key]] = request&#46;get(paramKeys[key]);
}
var email = requestParams['email'];
var newPass = requestParams['newPass'];
var code = requestParams['code'];
var allCorrect = false;
&#47;&#47;
&#47;&#47;here is your "check User collection" code&#46; Check is there user with E-mail == 'email' && secret_code = 'code'
&#47;&#47;this should help http:&#47;&#47;docs&#46;appery&#46;io&#47;documentation&#47;backendservices&#47;server-code&#47;#Database_API
&#47;&#47;set allCorrect = true if user was found
if (allCorrect) {
&#47;&#47;here is your "Update User collection" code&#46; Set new password&#46;
&#47;&#47;this should help http:&#47;&#47;docs&#46;appery&#46;io&#47;documentation&#47;backendservices&#47;server-code&#47;#Database_API
&#47;&#47;
responseBody&#46;message = "success&quot
} else {
responseBody&#46;message = "some error&quot
}
response&#46;success(responseBody, "application&#47;json");/pre


Forgot Password Service

Posted: Wed Sep 25, 2013 5:12 pm
by Doug Black

Thanks, I'll get to work! Appreciate all of your help on this!


Forgot Password Service

Posted: Sat Oct 12, 2013 4:10 am
by Deon

Hi Doug

Did you come right with this issue?

Thx