Janosch Hübner
Janosch Hübner

Reputation: 1694

Firebase Function onLink trigger

Is it possible to implement a function hook on when an anonymous user is linked to a normal account?

What I am trying to achieve in a secure way is:


1. DeepLink for invitation opens in the app.
2. Get invited_by from the URL and sign in the user anonymously, saving invited_by to invitations/anonymous_user_1/invited_by.
3. User registers an account and signs in so onCreate function is triggered, but we do not have access to the anonymous account there.
4. If there already is an anonymous account before registering, we link the anonymous account to the users new account.


And here is where I want to trigger a remote firebase function (don't want to trigger it on the client side, because it could be retriggered and abused to gain invitation advantages).

onLink() should do something like this:


1. Get old account (anonymous) and new account.
2. Get invitations/anonymous_user_1/invited_by from anonymous account.
3. Store it and perform actions on the new account.
4. Delete invitations/anonymous_user_1/invited_by once processed.


Is there a way to do this server side? Because onLink() would only be called once, and therefore I could process the anonymous data once. As I said I would not want to call a function locally.

Thanks

Upvotes: 0

Views: 139

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598847

There is no Firebase Authentication trigger for Cloud Functions when a user links accounts from multiple providers at the moment. As Doug commented, it's best to file a feature request for this.

Upvotes: 1

Related Questions