【发布时间】:2021-10-18 08:32:43
【问题描述】:
在使用firestore时,是否可以通过context.auth属性获取触发云功能的用户的uid?
exports.updateReport = functions.firestore
.document('groups/{groupId}/reports/{nursingId}')
.onUpdate((change, context) => {
const uid : string | undefined = context.auth?.uid;
})
我发现很多关于同一个问题的老问题有很多不同的回答。 (该功能有效,该功能可能会在某个时候有效,或者该功能永远不会有效)
在我的本地设置中,我 context.auth 始终未定义,所以我不知道我是否犯了错误,或者它根本不起作用。如果是这样的话,有没有其他安全的方法来获取用户的uid,谁触发了相应的云功能?
【问题讨论】:
标签: firebase google-cloud-firestore google-cloud-functions