Search code examples
angularjsfirebaseionic-frameworkfirebase-authenticationsparkpost

How to build a custom Firebase registration confirmation / validation / email reset


This is driving me completely bonkers. I cant use the firebase email system to notify the user about account validation email, email reset or email change becasue I cant change the language or template. So I started using Sparkpost. I already built most of its functionality, but I found that I cant obtaing the confirmation code for this actions.

Is there a way to use any of this functionalities without using the email system? Can I in any way obtain the "code" needed to execute:

[confirmPasswordReset(code, newPassword)][3]
[checkActionCode(code)][2]
[applyActionCode(code)][1]

If I can in any way obtain this code I could use a mix of sparkpost mail system and angular page to validate user or change password on my ionic app. Or I could make a node endpoint to do this operations.

I really need some help.


Solution

  • You cannot get the verification code through a public API.

    But you can verify user accounts in your server-side code directly (without calling checkActionCode/applyActionCode) by using the Firebase Admin SDK for Node.js.

    From the documentation on updating a user:

    The updateUser() method allows you to modify an existing user's data. It accepts a uid for the user to update as well as an object containing the UserRecord properties to update:

    admin.auth().updateUser(uid, {
      email: "modifiedUser@example.com",
      emailVerified: true,
      password: "newPassword",
      displayName: "Jane Doe",
      photoURL: "http://www.example.com/12345678/photo.png",
      disabled: true
    })
      .then(function(userRecord) {
        console.log("Successfully updated user", userRecord.toJSON());
      })
      .catch(function(error) {
        console.log("Error updating user:", error);
      });
    

    With this you can build your own verification mechanism and then simply update the user's status once you're done.