firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

[auth] `creationTime` is always equal to `lastSignInTime`

Open Lyokone opened this issue 1 year ago • 1 comments

Description

When signing in anonymously, then linking the anonymous with an email/password credential, we always get the creationDate and lastSignInDate equals even tho we didn't create and sign in at the same time.

First reported here: https://github.com/firebase/flutterfire/issues/9640

Reproducing the issue

[[FIRAuth auth] signInAnonymouslyWithCompletion:^(FIRAuthDataResult * _Nullable authResult,
                                                  NSError * _Nullable error) {
FIRAuthCredential *credential =
    [FIREmailAuthProvider credentialWithEmail:email
                                             password:password];
    [[FIRAuth auth].currentUser linkWithCredential:credential
    completion:^(FIRAuthDataResult *result, NSError *_Nullable error) {
// Expect creationDate and lastSignInDate to be different
}];

 }];

Firebase SDK Version

10.3.0

Xcode Version

14.2

Installation Method

CocoaPods

Firebase Product(s)

Authentication

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

Replace this line with the contents of your Podfile.lock!

Lyokone avatar Jan 09 '23 08:01 Lyokone

Thanks for reporting this, @Lyokone. Per checking, I was able to reproduce the same behavior, but it seems like this is intended because when you sign in using an anonymous account, it will automatically create an account with a UUID and then it will login at the same time. If this is not the case, please share detailed steps to reproduce the issue.

rizafran avatar Jan 10 '23 18:01 rizafran

Thanks for reporting this, @Lyokone. Per checking, I was able to reproduce the same behavior, but it seems like this is intended because when you sign in using an anonymous account, it will automatically create an account with a UUID and then it will login at the same time. If this is not the case, please share detailed steps to reproduce the issue.

Hello, I am the original poster of this issue in the flutterfire repo.

Just to clarify on the issue, the account has already been created/linked: It's when an app is launched that the creationTime and lastSignInTime are the same.

In addition, signing out and back in will return the correct creationTime and lastSignInTime if getting the metadata directly from the firebase auth instance, but not from the listener that returns the user's metadata, so there's some sort of disconnect there.

AdamBridges avatar Jan 12 '23 18:01 AdamBridges

Hi @AdamBridges, regarding this statement:

Just to clarify on the issue, the account has already been created/linked: It's when an app is launched that the creationTime and lastSignInTime are the same.

To see that we're on the same page, could you clarify the steps to replicate the issue below:

  1. Sign in anonymously
  2. Link to email/password account
  3. Sign out
  4. Sign in again using the email/pass account

If that's the case, I tested again and it's working fine on my end using the Auth.auth().addStateDidChangeListener since userChanges().listen is not available on native iOS.

rizafran avatar Jan 13 '23 14:01 rizafran

Hi @AdamBridges, regarding this statement:

Just to clarify on the issue, the account has already been created/linked: It's when an app is launched that the creationTime and lastSignInTime are the same.

To see that we're on the same page, could you clarify the steps to replicate the issue below:

  1. Sign in anonymously
  2. Link to email/password account
  3. Sign out
  4. Sign in again using the email/pass account

If that's the case, I tested again and it's working fine on my end using the Auth.auth().addStateDidChangeListener since userChanges().listen is not available on native iOS.

Okay, then it's possible that the issue still lies in the firebase_auth package of the flutterfire repo.

@Lyokone should be able to clarify further.

AdamBridges avatar Jan 13 '23 14:01 AdamBridges

Hey @Lyokone. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jan 20 '23 02:01 google-oss-bot

Thanks for investigating, I'll have another look on my end

Lyokone avatar Jan 20 '23 07:01 Lyokone

Hey @Lyokone. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jan 27 '23 02:01 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@Lyokone if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Feb 02 '23 02:02 google-oss-bot