On authentication triggers I am getting displayName as null

岁酱吖の 提交于 2021-01-29 08:52:07

问题


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;
})

回答1:


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.



来源:https://stackoverflow.com/questions/62433949/on-authentication-triggers-i-am-getting-displayname-as-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!