【发布时间】:2020-08-25 09:53:19
【问题描述】:
我在 Firebase 身份验证中更改电子邮件地址时遇到了一些问题。 我的代码现在看起来像这样:
func changeEmail(withEmail email: String, completion: @escaping ((Bool) -> Void)) {
guard let currentUser = Auth.auth().currentUser, let email = mail else { return }
currentUser.updateEmail(to: email) { [weak self]
error in
guard let self = self else { return }
let title: String
let message: String
if let error = error {
title = "alert.error.title".localized()
message = error.localizedDescription
} else {
title = email
message = "auth.confirm.email.popup".localized()
currentUser.sendEmailVerification()
}
self.navigator.showAlert(title: title,
message: message,
bottomLeftTitle: "general.got.it".localized(),
bottomLeftHandler: { completion(error == nil)
})
}
}
所以没关系,并且可以正常工作,并且用户实际上可以更改电子邮件。
但是当用户停留时间过长需要重新登录时会出现问题。每个人都知道这会扰乱应用中的用户体验。
Auth.auth().reload() //not working in this situation.
那么如何在不要求用户注销并重新登录的情况下更改电子邮件?
【问题讨论】:
标签: swift firebase firebase-authentication