1

I'm trying to send an email verification to users using firebase auth admin. All examples seem to use firebase.auth().currentUser;, however, in my case I am logged in as an admin user viewing a custom dashboard list of users to take action on rather than being logged in as an individual user.

I can successfully change a user record using this approach by passing in the UID to the updateUser method and the changes... e.g.

let userRecord = await fbAuth.updateUser(blogUID, {
          email: req.body.BloggerEmail
})

and can retrieve the userdetails of the user I want using:

    var userA = await fbAuth.getUser(blogUID)

However, the user object returned by this method does't allow me to call the sendEmailVerification method (it appears getUser doesn't return the same object type as getCurrentUser

    try {
        var userA = await fbAuth.getUser(blogUID).sendEmailVerification()
        console.log("Sent new verification email");
    } catch(error) {
        console.log("Error sending verification email " + error);
    }

[this fails, sendEmailVerification is not a method]

Official Reference Doc I've tried to use: https://firebase.google.com/docs/auth/web/manage-users#send_a_user_a_verification_email

Appreciate your help.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Daz
  • 71
  • 2
  • 5

1 Answers1

1

Since your code uses the Admin SDK to look up a user by their UID, it can only call methods from the Admin SDK. You can't simply match methods from the Admin SDK and the client-side SDKs.

Since the Admin SDK doesn't have a method to send a verification email (see this), you will either have to let the client do this, or implement your own email verification flow. See firebase admin SDK create user and send verification email

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I've reviewed the article - this makes sense, I will also raise another change request to Firebase. – Daz Feb 20 '19 at 23:37