parse-community / Parse-SDK-JS

The JavaScript SDK for Parse Platform
https://parseplatform.org
Apache License 2.0
1.33k stars 597 forks source link

Parse.User.requestPasswordReset throws no errors if issue is serverside #1085

Open REPTILEHAUS opened 4 years ago

REPTILEHAUS commented 4 years ago

Cant get an error from password reset , there is a problem where if you have an EU registered mailgun account that you must specify the endpoints for parse email adapter as such with additional host param set to "api.eu.mailgun.net"

    parseConfig.emailAdapter = {
        module: '@parse/simple-mailgun-adapter',
        options: {
            fromAddress: config.mailgun.from,
            domain: config.mailgun.domain,
            apiKey: config.mailgun.key,
            host: "api.eu.mailgun.net"     
        }
    }

however no error got thrown on the frontend using this code - but errors on parse server where getting thrown, as this is an internal parse server function, how should we handle its errors (in async fashion)

            resetPassword(email: string): Promise<any> {
                return Parse.User.requestPasswordReset(email, {
                    success: () => {
                    console.log("success")
                    },
                    error: (error) => {
                        console.log("error "+ error)
                    }
                });
            }

The desired effect is that if there is no error I can redirect back to login page and allow the user to login after success resetting their pw

davimacedo commented 4 years ago

I really didn't get your point. Are you using this code on the client side? Isn't it firing the error callback when some error happens?

REPTILEHAUS commented 4 years ago

Yes, the error callback is not triggered

davimacedo commented 4 years ago

You share there is an error showing up in the Parse Server logs, right? Could you share the error?

dplewis commented 4 years ago

@REPTILEHAUS Shouldn't this cause the server to fail on start up.

Also the mail gun adapter sendMail returns a promise here. The server doesn't resolve the promise here.

@davimacedo Does this look right?

davimacedo commented 4 years ago

I believe that it makes sense to not wait for the promise to complete. It would delay the sign up process. We could catch and log any possible error though.