FirebaseUI-iOS icon indicating copy to clipboard operation
FirebaseUI-iOS copied to clipboard

Auth.auth().currentUser.isAnonymous is not correctly updated after linking Apple Login

Open Johnson145 opened this issue 4 years ago • 3 comments

Step 2: Describe your environment

  • Objective C or Swift: Swift
  • iOS version: 13.3
  • Firebase SDK version: 6.6.2
  • FirebaseUI version: 8.4.1
  • CocoaPods Version: 1.8.4

Step 3: Describe the problem:

When migrating an anonymous user to a non-anonymous one by choosing the Login with Apple ID, the Auth.auth().currentUser.isAnonymous isn't updated and the attribute remains false.

Steps to reproduce:

  1. (Programatically) log in with an anonymous user
  2. Open the Firebase UI login screen with authUI.shouldAutoUpgradeAnonymousUsers = true
  3. Log in with an Apple ID
  4. Listen for the callback in func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?)

Observed Results:

  • Auth.auth().currentUser.isAnonymous is still true
  • authDataResult?.user.isAnonymous is false

Expected Results:

  • Auth.auth().currentUser.isAnonymous has the same value as the user provided in the callback parameter, i.e. it's false

Further notes

  • When using other login methods, the two values are correctly synced.
  • There used to be a similar issue (#651) for the email login.
  • Not sure, whether this is a Firebase UI issue or a Firebase (Auth) issue in general.

Johnson145 avatar Mar 03 '20 16:03 Johnson145

I haven't tested this myself, but I'm planning to support anonymous users and apple sign-in, so this would be a high priority request for myself as well. I'll comment again if I see the same issue.

joeljfischer avatar Jul 01 '20 20:07 joeljfischer

I've filed a bug internally as b/160627975.


@joeljfischer This bug is about Auth.auth().currentUser.isAnonymous not being updated. However, linking an anon user with Apple Sign-in still works fine (minus this bug).

As OP mentioned, you just need to use authDataResult?.user.isAnonymous instead of Auth.auth().currentUser.isAnonymous for now to detect if a user has been upgraded or not for now. This workaround should be temporary and will not need be needed once we fix the bug.

yuchenshi avatar Jul 06 '20 20:07 yuchenshi

@yuchenshi Thank you for the clarification.

joeljfischer avatar Jul 07 '20 17:07 joeljfischer