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

标签 firebase firebase-authentication google-cloud-functions

有没有办法检查电子邮件是否通过云功能验证 即,如果我有用户的 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/

相关文章:

android - 将 android studio 项目与 Firebase 集成以实现 google 登录功能时出现依赖错误

firebase - 使用 Stackdriver 调试 Firebase Cloud Functions

ios - FaSTLane Scan 的构建过程缺少 Jenkins CI 上的 CocoaPod 框架

swift - 从 Firebase 转换时间戳并添加到数组

android - window.FirebasePlugin.verifyPhoneNumber 函数响应无法使用

java - 使用 Google Play 游戏进行 Firebase 身份验证

typescript - 模拟器的 Firebase 功能,部署时忽略

node.js - 如何在谷歌云中自动化 NodeJS 脚本

typescript - 如何使用Firebase模拟器pubsub在本地测试定时功能?

flutter - 在 flutter 中使用 Firebase 实时数据库数据创建无限滚动效果