Skip to content

existing user modification time and new user signup timestamps are same #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
j2emanue opened this issue Mar 25, 2018 · 10 comments
Closed

Comments

@j2emanue
Copy link

j2emanue commented Mar 25, 2018

It seems the check to verify if the user is a new SignUp or existing user is not working.

I signed up a user brand new and then logged out of email provider.

I then logged in again (and got the welcome back screen) and signed in again.

I did this immediately with about 10 seconds delay between:

but the following code always returns true:

  public boolean isNewSignUp() {
       FirebaseUserMetadata metadata = mAuth.getCurrentUser().getMetadata();
       if (metadata.getCreationTimestamp() == metadata.getLastSignInTimestamp()) {
           Toast.makeText(getActivity(), "new user ACCOUNT CREATED", Toast.LENGTH_LONG).show();
       } else {
           // This is an existing user, show them a welcome back screen.

           Toast.makeText(getActivity(), "existing user account retrieved", Toast.LENGTH_LONG).show();
       }

       return metadata.getCreationTimestamp() == metadata.getLastSignInTimestamp();
   }

i am using fireBaseUI-Auth and this check happens in onActivityResult. What am i missing ?

@SUPERCILEX
Copy link
Collaborator

What version of FUI and play services are you using?

@j2emanue
Copy link
Author

j2emanue commented Mar 25, 2018 via email

@huberrom
Copy link

huberrom commented Apr 4, 2018

Got the same problem

@j2emanue
Copy link
Author

j2emanue commented Apr 4, 2018

im on the latest android and google play services now. tried it again and same issue. its kind of important issue as when we know its a new user account we'd like to show a screen such as select your country or select your preference for the application before proceeding. @huberrom have you thought of any temporary solution

@samtstern
Copy link
Contributor

I just tried this with the demo app in this repository and I cannot reproduce. I signed in with an existing email user and got:

created:1518803610000
   last:1522860101000

@j2emanue
Copy link
Author

j2emanue commented Apr 4, 2018

samtstern, do it this way instead. create a new account and immediately sign out and log in again with the same account. on api 26 emulator is what i was using with google play services 12.0.1 but even previous version it occurs.

@samtstern
Copy link
Contributor

@j2emanue thanks! That reproduced it for me:

created:1522861280000
   last:1522861280000

This is almost definitely a bug in the Firebase Auth SDK, I will file it with them. Could you see if calling reload() helps you?:
https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseUser.html#reload()

@samtstern
Copy link
Contributor

@j2emanue ok I just talked to the team and they said:

The granularity accuracy that Firebear server guarantees for the last_login timestamp is 1 minute. The reason is to avoid too frequent write operation to [the backend].

The real source of true here is the isNewUser() method on the AdditionalUserInfo returned in the AuthResult, but off the top of my head I don't think we provide any way for you to get to that from FirebaseUI.

@samtstern
Copy link
Contributor

Going to close this and file a new feature request to expose that information,

@j2emanue
Copy link
Author

j2emanue commented Apr 5, 2018

@samtstern it happens in other scenarios. i had an account that has existed for a few days and when i log in it says its a new account. i then go on firebase console and check the creation time and its from a few days ago. so its happening in other scenarios. @SUPERCILEX is there anyway you can put a boolean in the intent when onActivityResult is called so that we can know if its a new user, as a temporary fix ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants