Upgrade anonymous user with PhoneAuthProvider

62 views
Skip to first unread message

Esdras Eduardo

unread,
Feb 2, 2021, 5:21:54 AM2/2/21
to Firebase Google Group
Hello everyone, I am having issues to sign in/up properly in my application.

Every new session I create an anonymous user, the user can use the same form to do the sign in or sign up using their phone number, and that is the problem if I do `firebase.auth().signInWithCredential` the customer already created will work well but for new customers the firebase will create new user instead of upgrade the anonymous user already created., with that I lost my user tracking.
To upgrade anonymous user I can use `user.linkWithCredential`, it will work well for new users but for user already created I will get `auth/provider-already-linked` because the credentials are being used to another user, it is correct because I need to do a sign in here, but if I try to do `firebase.auth().signInWithCredential` right after that the `linkWithCredentials` I got the error `auth/code-expired` because the user already have used pin received by SMS.

The idea is resolve this issue without implemented a backend implementing, for example request to backend if the number is already being used.

Any tip to my?

Thanks

Esdras
Reply all
Reply to author
Forward
0 new messages