创建新用户时,我需要注销他们,然后发送验证电子邮件以确保他们拥有该电子邮件地址。目前,我的代码创建了用户并执行了“ sendEmailVerification”调用,但使用户保持登录状态。如何注销用户并检查他们是否已验证电子邮件?
func signUp(with email: String, password: String, firstName: String, lastName: String) {
self.presentActivityView()
Auth.auth().createUser(withEmail: email, password: password) {[unowned self] (user, error) in
DispatchQueue.main.async { [unowned self] in
self.dismissActivityView()
if let err = error {
self.addAlertController(title: "Error!", message: err.localizedDescription)
} else {
let changeReq = Auth.auth().currentUser?.createProfileChangeRequest()
changeReq?.displayName = firstName + " " + lastName
if let url = self.profilePicURLString {
changeReq?.photoURL = URL(string: url)
}
changeReq?.commitChanges(completion: { (error) in
if error == nil {
//Profile updated successfully
}else {
//Profile not updated successfully
}
})
Auth.auth().currentUser?.sendEmailVerification(completion: { (error) in
if error == nil {
//Verification initiated successfully
}else {
print("Error: \(error)")
}
})
let vc = MainStoryboard.instantiateViewController(withIdentifier: "SNStoryFeedController") as! SNStoryFeedController
let nc = UINavigationController(rootViewController: vc)
UIApplication.shared.keyWindow?.rootViewController = nc
}
}
}
}
答案 0 :(得分:0)
您唯一需要做的就是从您自己的应用程序中注销:
// for FIRAuth
try? Auth.auth()?.signOut()
// for GoogleSignIn
GIDSignIn.sharedInstance().signOut()
safari部分由系统处理,您无需担心。