David
David

Reputation: 3184

Trigger firebase function on anonymous user upgrade

Firebase functions provide a functions.auth.user().onCreate() and functions.auth.user().onDelete() handler. However when an anonymous user is linked to a new email user using linkWithCredential() as follows no action is triggered. Is there a way to handle and be notified of such occurances within Firebase functions?

auth.currentUser.linkWithCredential(credential)
  .then(function(usercred) {
    var user = usercred.user;
    console.log("Anonymous account successfully upgraded", user);
  }).catch(function(error) {
    console.log("Error upgrading anonymous account", error);
  });

Upvotes: 1

Views: 218

Answers (2)

Saccarab
Saccarab

Reputation: 1511

I believe you can now use blocking functions to get around this. Since I assume a sign-in event will be fired after linkWithCredential() you should be able to capture the account upgrade event.

Upvotes: 1

Doug Stevenson
Doug Stevenson

Reputation: 317372

There is no trigger for this event. There is just account creation and deletion. This would be a feature request that you could file with Firebase support.

Upvotes: 1

Related Questions