2

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.

Pablo Palacios
  • 2,767
  • 20
  • 37

1 Answers1

1

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thank you a lot, this actually helps me a lot, because now I can make a document and store my own validation key in order to activate the account. About reset, I just learned that that is the only email template I can modify. Thanks. – Pablo Palacios Dec 14 '16 at 12:53
  • I ended creating a Lambda service, where I uploaded de Admin Node package, Now I can manage users from my serverless app. Thanks its working. – Pablo Palacios Dec 16 '16 at 17:27
  • That sounds pretty cool Pablo! If you feel like writing your own answer or a blog post about it, I'm quite sure it'd be useful to more people. – Frank van Puffelen Dec 16 '16 at 17:47