gpt4 book ai didi

Firebase:如果验证了用户电子邮件,则通过云功能进行检查

转载 作者:行者123 更新时间:2023-12-05 03:05:17 24 4
gpt4 key购买 nike

有没有办法检查电子邮件是否通过云功能验证即,如果我有用户的 uid,我可以检查电子邮件是否已针对该特定用户进行验证。在我的用例中,我需要确保在执行交易之前验证电子邮件。我想检查它的服务器端

示例云函数:

exports.executeTransaction = functions.https.onCall((data,context)=>{ 

const userid = context.auth.uid

//Check if email is verified
//I want to use context variable to somehow extract whether email is verified. Is there a way to do it ?
//Execute Transaction if email is verified
})

最佳答案

没关系,我设法弄明白了。

对于有类似问题的任何人,请参阅以下内容:

exports.executeTransaction = functions.https.onCall((data,context)=>{ 
const userid = context.auth.uid
//Check if email is verified
return admin.auth().getUser(context.auth.uid).then(user => {
//Check if email verified
if(user.emailVerified)
{
return "Verified"
}
else{
console.log("User Email not verified")
return "Not Verified"
}
}).catch(function(err){
console.log(err)
throw new functions.https.HttpsError('Error Validating', err.message, err)
})
})

关于Firebase:如果验证了用户电子邮件,则通过云功能进行检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51147266/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com