【发布时间】:2017-02-23 10:54:23
【问题描述】:
我检查了用户是否通过电子邮件验证。但是,无论我发送多少封邮件并确认,验证状态仍然是false。检查时我做错了吗?
FIRAuth.auth()?.addStateDidChangeListener({ (auth, user) in
if (auth.currentUser?.isEmailVerified)!{
let mainStoryboard: UIStoryboard = UIStoryboard(name:"Main",bundle:nil)
let NewPostViewController: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "NewPostViewController")
//Send the user to the LoginViewController
self.present(NewPostViewController, animated: true, completion: nil)
}else{
let alertVC = UIAlertController(title: "Error", message: "Sorry. Your email address has not yet been verified. Do you want us to send another verification email to \(self.currentUser.generalDetails.email).", preferredStyle: .alert)
let alertActionOkay = UIAlertAction(title: "Okay", style: .default) {
(_) in
FIRAuth.auth()?.currentUser?.sendEmailVerification(completion: nil)
}
let alertActionCancel = UIAlertAction(title: "Cancel", style: .default, handler: nil)
alertVC.addAction(alertActionOkay)
alertVC.addAction(alertActionCancel)
self.present(alertVC, animated: true, completion: nil)
}
})
【问题讨论】:
-
验证用户后是否要重新加载当前用户?
-
如何重新加载用户?终止应用程序不会成功吗?如果它正在重新加载我的声誉,那么为什么它没有检测到用户已通过验证。
-
电子邮件验证属性仅在用户登录时重新加载。如果我没记错的话,您可以re-authenticate 获取更新后的值,但
reloadWithCompletion听起来也很有希望。 -
谢谢。得到它的工作:) 我什至没有想到必须做这样的事情。我认为 Firebase 会为用户添加一些标记,否则会完全不同,因为文档对此非常糟糕。即使我尝试自己找到这些价值观,如果我去文档,我也找不到它们:D 每天都在学习新事物。
标签: ios swift firebase firebase-authentication