Sachin Kumar
Sachin Kumar

Reputation: 406

On authentication triggers I am getting displayName as null

I want to use users data on authentication trigger. But when I am using them it gives me null. What is wrong with my code?

exports.sendWelcomeMessage = functions.auth.user().onCreate((user) => {
    const name = user.displayName;
    console.log(name);
    return null;
})

Upvotes: 0

Views: 67

Answers (1)

bojeil
bojeil

Reputation: 30838

I speculate you are creating the user and then setting the display name (eg via 2 calls).

onCreate triggers as soon as the user is created, eg createUserWithEmailAndPassword.

When you call updateProfile to set the displayName, the onCreate event would have already been triggered.

Upvotes: 1

Related Questions