iOS FIRAuth : Is there any way to get user email from user uid?

标签 ios swift firebase firebase-authentication

我试图让用户使用用户名进行身份验证。数据库存储敏感数据,因此我们避免在数据库中存储电子邮件(因为电子邮件是识别数据)。

目前,数据库存储用户的自定义 用户名 以及关联的 FIRAuth UID

我想知道我们是否有任何方法可以根据 FIRAuth UID 获取用户电子邮件,以便我们可以让用户登录?

编辑:这是在用户登录之前,所以 .currentUser 没有帮助

谢谢!

最佳答案

要获取用户的个人资料信息,请使用 FIRUser 实例的属性,如下所示:

let user = Auth.auth().currentUser
if let user = user {
  let uid = user.uid
  let email = user.email
  let photoURL = user.photoURL
  // ...
}

关于iOS FIRAuth : Is there any way to get user email from user uid?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51346492/

相关文章:

ios - 在UITableViewCell中为detailTextLabel添加右边距

ios - 归档应用程序时为 "Use of unresolved identifier"

swift - 带有超链接文本的 UITextView

javascript - Google Cloud Function 未定义参数检测为 null

ios - 我可以使用iOS内置的安全性锁定应用程序吗

ios - 使用 NSASCIIStringEncoding 对 NSString 进行编码

ios - 实现 Alamofire.NetworkReachabilityManager 供全局使用

ios - Swift - removeAllAnimations() - 一个接一个的动画

android - 在 RecyclerView 中显示 Firebase 数据库的最后一个子级、第一个子级

android - Firebase 定期更新数据库