Eric Larson
Eric Larson

Reputation: 519

Firebase Functions Trigger on Account Link

I want to store email information on user documents when a user is created. For standard users who use email and password to sign up, I can simply call auth.user().onCreate and set the email on the user document. For users who sign in anonymously, and then later link their email, how can I get the email set on the user document? Is there a way to do this with Firestore triggers only? Does a user().onUpdate function exist? I want to avoid client side code that updates user documents.

Upvotes: 5

Views: 410

Answers (2)

Christer
Christer

Reputation: 3076

I guess you can do something like this.

functions.auth.user().onCreate((user) => {
  if(!user.isAnonymous){
    //create an instance in firestore
    // ... 
  }
});

Upvotes: 0

Frank van Puffelen
Frank van Puffelen

Reputation: 598728

firebaser here

There is currently no trigger when an account is linked (or updated in general). I'd recommend you file a feature request to weigh in.

Upvotes: 3

Related Questions