在Firebase Firestore Cloud函数中获取当前用户的uid

时间:2019-01-06 21:33:49

标签: google-cloud-firestore google-cloud-functions

是否可以在firebase firestore云功能中获取当前用户的uid。我尝试了一个示例代码,但是它总是会引发错误;有什么方法可以实现此功能?

这是我的代码:

me { ... }

此代码始终会引发错误;我不知道为什么?

  exports.test = functions.firestore.document('test/{doc}')
.onCreate(async (snap, context) => {
    const db = admin.auth();
    const uid = context.auth.uid;
    console.log(context.auth.uid, 'is the uid of cuurent user');
    console.log(db.getUser(uid), 'is the current user');
    return;
});

0 个答案:

没有答案