question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

firebase create user by email not returning displayName using ui 2.3.0

See original GitHub issue

seeing this issue closed several times in here, I am little shocked I have to post this issue.

using a simple firebase function, and using code very similar to the example here: https://firebase.google.com/docs/reference/functions/functions.auth.UserBuilder#onCreate

and using the sign in by email method on the firebase ui, and having the user sign up with first and last name,

my firebase function:

exports.createAccount = functions.auth.user().onCreate(function(event) {
	const data = event.data;
	console.log(data);
});

and the firebase function log shows me:

{ email: 'yoda@example.com',
  metadata: 
   { createdAt: 2017-07-28T14:29:08.000Z,
     lastSignedInAt: 2017-07-28T14:29:08.000Z },
  uid: 'xxxxxxxxxxx' }

where is yoda’s displayName (should be: Yoda Yo) which he entered in firebase ui?

And, so if I used the entire example in the link I posted above, how am I supposed to send yoda a personalized sign up email using his first name, when firebase ui doesn’t even return it?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
nyveliuscommented, Feb 20, 2018

I have a functional setup using a delay, but it does create a race condition. It seems a nicer solution would be to add an onUpdate trigger on the UserBuilder object (maybe this is already on a todo list somewhere?).

functions.auth.user().onUpdate(...)

3reactions
jm93commented, Jul 29, 2017

okay then. thanks for this new info.

how about somewhere, the firebase team mention in ui or user creation documentation that email sign up does not act as expected or the same as other provider sign up. or fix it so they all work the same, ie don’t return a user until all profile info like displayName is ready.

in the meantime - any suggestion HOW to actually get the user displayName upon creation from email sign up using ui?

Update: nevermind, able to pull user info with a promise after email signup:

exports.createAccount = functions.auth.user().onCreate(function(event) {
	const data = event.data;
	console.log(data);
	admin.auth().getUser(data.uid)
  .then(function(userRecord) {
    console.log("Successfully fetched user data:", userRecord.toJSON());
  })
  .catch(function(error) {
    console.log("Error fetching user data:", error);
  });
});

functions console shows displayName:

Successfully fetched user data: { uid: 'xxxxxxxx',
  email: 'yoda@example.com',
  emailVerified: false,
  displayName: 'yoda yo',
  photoURL: undefined,
  disabled: false,
  metadata: 
   { lastSignedInAt: 2017-07-29T12:50:54.000Z,
     createdAt: 2017-07-29T12:50:54.000Z },
  providerData: 
   [ { uid: 'yoda@example.com',
       displayName: 'yoda yo',
       email: 'yoda@example.com',
       photoURL: undefined,
       providerId: 'password' } ] }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage Users in Firebase - Google
You create a new user in your Firebase project by calling the createUserWithEmailAndPassword method or by signing in a user for the first...
Read more >
User displayName returns null in Firebase Auth - Stack Overflow
Turns out that fetching displayName during UserCredential registration still gets null. Try fetching displayName using currentUser . I've tried ...
Read more >
Update Username and Scrollfix - Firebase Profile - Part III
Today we want to update the username inside of our # Firebase #Profile. Besides that, we fix a Pixel Overflow problem whenever we...
Read more >
User management - Firebase Admin SDK for PHP
The uid to assign to the newly created user. Must be a string between 1 and 128 characters long, inclusive. If not provided,...
Read more >
Chapter 19 Firebase | Client-Side Web Development
It's possible to have users sign up with an email and password, ... Make sure you're creating the Realtime Database, not the Firestore...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found