I am attempting to setup my own custom password reset for the Parse Server as at the time it doesn't have that functionality.
I have followed this tutorial on stack overflow --> How to set up a Parse Server Using Heroku
I've also read through this issue on Github --> Tips for implementing password reset?
Here is what I have been following as a guide that was said on the Github issue:
An express route or a cloud function to handle a password reset submission, which queries for a user matching the username/email. Generate a one-time random code and save it somewhere along with the user... Email the user, using some mail provider, with a link.
An express route to handle the link, which takes the random code provided and searches for the user, validates it, and then presents them with the ability to provide a new password... Use the master key to override the password and save the user.
I have managed to complete the first paragraph, emailing the user with a link. Now I am trying to setup an express route that handles the link, and queries for the user, however my parse query doesn't seem to be working at all and heroku keeps timing out.
Here is my code in my index.js
(the default class that comes with the parse server) for setting up an express route that takes the user's name
from the link and does a query that gets the user and then sends their username
.
*Note I know getting a user's name
and then querying isn't scalable it is merely for testing purposes only.
//Testing web routes
app.get('/route', function(req, res) {
var query = new Parse.Query("_User");
query.equalTo("name", req.param("id"));
query.get({
success: function(user) {
res.status(200).send(user.get("username"));
},
error: function(error) {
res.status(200).send("error");
}
});
});
This is the link I click through:
What then happens that I don't understand is the page keeps loading and then after about 30 seconds heroku times out and shows this error on the webpage:
Then when I check my logs on heroku:
I notice this error:
at=error code=H12 desc="Request timeout" method=GET path="/route?id=John%20Smith"
The part that I don't understand is that even if there was an error with my parse query it should just send "error" because of the error handler and this line of code : res.status(200).send("error");
.
I also know that the web route itself is working because I've tried this code:
//Testing web routes
app.get('/route', function(req, res) {
res.status(200).send("Hello world");
});
And the website receives the "Hello world" text.
What is causing the time out error and why isn't my query working at all?