Search code examples
parse-platformparse-server

Re-sending email verification with Parse


I am not sure if I just did not see it or it is not obvious but is there a way for either Javascript SDK or REST API of Parse to re-send verification email to specific username/email that signed up and did not get the email for whatever reason?


Solution

  • I faced this issue few years ago and as far as I remember there was no way to resend the verification Email directly via the Parse SDK. The Email verification was being triggered automatically when the Email field was being populated first or updated.

    As a workaround, I implemented a cloud function to overwrite the Email field to trigger a resend. The function stored the original Email address value in a temp variable and then replaced the Email field with a randomly generated valid Email address, then repopulate it again with the original Email address immediately. This used to trigger an Email resend from the Parse server.

    The code was something like this:

        var user  = request.user;
        var email = user.get("Email");
        var randomMail = "[email protected]"; //// random but valid Email address
        user.set("email", randomMail); /// Populate the field
    
        user.save(null, { useMasterKey: true }).then( function(user) {
    
            // The field was updated, recover the original Email address again
            user.set("email", email);
            return user.save(null, { useMasterKey: true });
    
        }).then( function(user) {
    
            response.success();
    
        }, function(error) {
    
            response.error(error);
        });