firebase / firebaseui-web

FirebaseUI is an open-source JavaScript library for Web that provides simple, customizable UI bindings on top of Firebase SDKs to eliminate boilerplate code and promote best practices.
https://firebase.google.com/
Apache License 2.0
4.58k stars 1.06k forks source link

displayName is null after login in #36

Closed sruditsky closed 8 years ago

sruditsky commented 8 years ago

I have been using firebaseui-web for sometime and it worked well. However, several days ago I noticed that for every new signed up user the displayName field of the user object (reported by onAuthStateChanged's callback) is null.

When a user goes through the sign up process he/she is asked to enter the name and such name is entered, however, after login the user structure does not contain this name.

This happens only with new signed up users. With users signed up long ago the displayName still contains the correct value.

bojeil-google commented 8 years ago

I'm unable to reproduce this. I am assuming you are talking about new email/password accounts. I signed up a couple of new users and logged out and then signed in again using the same accounts and the display name was intact.

sruditsky commented 8 years ago

Right now I have several users in this state. I have log the first line in the callback:

    firebase.auth().onAuthStateChanged(function(user) {
      console.log(JSON.stringify(user));

and get: {"displayName":null,"photoURL":null,"email":"sa...

Which I assume should be impossible to get...

Is there any way to see displayName information directly in firebase Auth console? Is there any information I can share to help debug this?

alfongj commented 8 years ago

Hi! Could you please file a ticket in https://firebase.google.com/support/contact/troubleshooting/ and include:

1) A reference to this issue 2) uids and full emails of the accounts affected 3) Mention to route this to my name

That way we can take a look more efficiently and without you having to share information about your users publicly :)

bojeil-google commented 8 years ago

Ok i am pretty certain I know what's going on. During email/password sign up, the following steps occur:

  1. createUserWithEmailAndPassword will create the new account with the email and password.
  2. updateProfile is called on the currentUser
  3. firebaseui callback run or signInSuccessUrl redirected to.

You likely have an onAuthStateChanged listener setup where you do something like this: var unsubscribe = firebase.auth().onAuthStateChanged(function(user) { if (user) { // Either user already signed in or in the middle of a sign in process. // display signed in screen. // This is interrupting step 2 and all users have no display name set. // If you unsubscribe quickly after first call, this will not interrupt the update profile on second call. } else { // No signed in, render sign in widget. ui.start(...); } // Unsubscribe after first trigger and rely on the signInSuccess callback to trigger to detect sign in completion reliably. unsubscribe(); });

We are adding an isPending method to confirm the sign in process is still in progress: https://github.com/firebase/firebaseui-web/issues/34

TMSCH commented 8 years ago

Hi @sruditsky, This issue has been fixed as part of the new release. We found a way to avoid it without adding extra work for developer. Please see the release notes: https://github.com/firebase/firebaseui-web#050 and have a look at the demo app to see a new SPA example.

vitnuk commented 7 years ago

This issue is still the case. I'm trying to use firebase-ui-auth-1.0.0 in sample app and in my app, but displayName is null after Sign Up with Email provider. You need to sign out and sign in again to actually get the displayName. Is there a way to get it working?

sruditsky commented 7 years ago

You are probably describing a slightly different situation than (#36). I do not think that in the original problem "sign out/sign in" would helped.

Anyway, to deal with the original problem I was told to take into account that onAuthStateChanged may be called several times and

the times where user.displayName == null should be ignored.


From: vitnuk notifications@github.com Sent: Sunday, November 13, 2016 6:41 AM To: firebase/firebaseui-web Cc: sruditsky; Mention Subject: Re: [firebase/firebaseui-web] displayName is null after login in (#36)

This issue is still the case. I'm trying to use firebase-ui-auth-1.0.0 in sample app and in my app, but displayName is null after Sign Up with Email provider. You need to sign out and sign in again to actually get the displayName. Is there a way to get it working?

You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/firebase/firebaseui-web/issues/36#issuecomment-260180982, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIA435kQ-YoCYWQw-ujTEFMjSbITN7byks5q9vdgaJpZM4Jjbq.

TMSCH commented 7 years ago

As part of the 0.5.0 release, this issue should have been fixed. The onAuthStateChanged should only be called at the end of the sign-in/sign-up flow, with the displayName set. @vitnuk, let's track this potential new bug in the other issue you opened, #67. @sruditsky, are you still observing that the observer is called several times during the sign-in/sign-up process with FirebaseUI?

sruditsky commented 7 years ago

No. I do not. Just tested this with the new version of FirebaseUI and I cannot reproduce it.


From: Thomas Césaré-Herriau notifications@github.com Sent: Sunday, November 13, 2016 3:18 PM To: firebase/firebaseui-web Cc: sruditsky; Mention Subject: Re: [firebase/firebaseui-web] displayName is null after login in (#36)

As part of the 0.5.0 release, this issue should have been fixed. The onAuthStateChanged should only be called at the end of the sign-in/sign-up flow, with the displayName set. @vitnukhttps://github.com/vitnuk, let's track this potential new bug in the other issue you opened, #67https://github.com/firebase/firebaseui-web/issues/67. @sruditskyhttps://github.com/sruditsky, are you still observing that the observer is called several times during the sign-in/sign-up process with FirebaseUI?

You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/firebase/firebaseui-web/issues/36#issuecomment-260209592, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIA436OBFHhSP9Fi1SDFrZIxBExAve3dks5q93CLgaJpZM4Jjbq_.

TMSCH commented 7 years ago

Great! Thanks for testing it.

Akshit94 commented 7 years ago

hey @sruditsky have you found a solution yet? I am also facing the exact same problem... EDIT so sorry I didn't saw the issue was closed...I will ask my question in #67

ampyard-akshay-sushir commented 2 years ago

If we register new user with email and password using createUserWithEmailAndPassword(email, password) it only takes two arguments email & password from input and it does not save user name in firebase. To fix this issue we have to update user name in firebase using updateProfile method after user is registered. Check following example:

const res = await auth.createUserWithEmailAndPassword(email, password);
const user = res.user;

// once we get user object then update user display name using following method
await user.updateProfile({displayName: name})

See my detail answer on stackoverflow Update user display name Check reference from firebase here: How to update user profile