繁体   English   中英

Firebase 云函数获取用户 UID

[英]Firebase cloud funtions get user UID

我已经编写了一个 firebase 云函数来在用户成功注册后获取注册用户 UID。

但代码不返回 UID 并返回空。 谁能帮我解决这个问题我相信 auth.user 无法获得 UID。 有没有人写过获取UID的代码?

exports.sendOTB = functions.auth.user().onCreate((event) => {
    firebase.auth().onAuthStateChanged(function(user) {
        if (user) {
            userID = user.uid;
            // User is signed in.
        } else {
            // No user is signed in.
        }
    }
});

试试这个:

exports.sendOTB = functions.auth.user().onCreate((event) => {

 const user = event.data;
 const email = user.email;
 const userid = user.uid;

 });

更多信息在这里:

https://firebase.google.com/docs/reference/functions/functions.auth.UserRecord

也根据这个答案:

https://stackoverflow.com/a/46452975/7015400

您无法知道云功能中的登录事件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM