1

I'm trying to create a cloud function that will listen for when users are created, and then send an email verification to the user that was created.

I have this code:

export const verifyEmail = functions.auth.user().onCreate((user) => {

});

The problem I have here is that user gives me no way of accessing sendEmailVerification. The only way of accessing that function is via the currentUser, but since this happens in a cloud function reaction to onCreate there is no current user.

I need to somehow get a firebase.User instance instead of a firebase.UserRecord, as the onCreate gives me.

How can I solve this?

Chrillewoodz
  • 27,055
  • 21
  • 92
  • 175

1 Answers1

2

There is no way to get the client-side user from the server, nor is there a way to send verification emails through the Admin SDK.

You will either have to trigger the email from the app itself, or send your own verification email. In the latter case, you can still use the existing verification service, by generating the correct email verification link.

Also see How to send email verification after user creation with Firebase Cloud functions?, which I'll actually mark your question as a duplicate of.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807