EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 448 forks source link

Reauthenticate with phone number #1705

Open burkongla opened 3 years ago

burkongla commented 3 years ago

Hi, We want to first authenticate with phone, thereafter we want to link email and password to the account as well. However, if the user closes the app before linking email and password and then tries to link it later we get the following error (at least on android):

Logging in the user failed. com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException: This operation is sensitive and requires recent authentication. Log in again before retrying this request

This is after the following sequence: of events:

  1. Register user with phone number.
  2. Exit application before linking email and password (is a part of the onboarding process).
  3. Wait a few minutes or so.
  4. Open app again and link (login) using email and password while still authenticated with phone number.

This is what we use to link/login with email and password: await firebase.login({ type: firebase.LoginType.PASSWORD, passwordOptions: { email: email, password: password, }, });

nativescript-plugin-firebase: "10.5.2"

Tried the "reauthenticate" function just in case, but that is only for email/password, google and facebook.

Just to clarify, if the user links the email and password immediately afterwards there is no issue.

I did try to use firebase.login with phone number again before without logging out first and that did not help.

One possible solution is to log the user out completely and then have them log themselves inn again, is this the preferred approach?

Any thoughts?