当用户通过电子邮件注册时,他们会获得他们提供给用户验证的电子邮件的验证链接。我希望未验证其电子邮件的用户无法登录或进入主屏幕,直到他们验证他们的电子邮件。这是我的代码。
@IBAction func emailRegisterButtonPressed(_ sender: Any) {
if emailTextField.text != "" && nameTextField.text != "" && lastnameTextField.text != "" && passwordTextField.text != "" {
FUser.registerUserwith(email: emailTextField.text!, password: passwordTextField.text!, firstName: nameTextField.text!, lastName: lastnameTextField.text!, completion: {(error) in
if error != nil {
print (" Error registering user with email: \(error?.localizedDescription)")
return
}
Auth.auth().currentUser?.sendEmailVerification { (error) in
// ...
ProgressHUD.showSuccess("please validate your email")
}
})
}
}
@IBAction func loginVC(_ sender: Any) {
if ( email is not verified << Code here ) {
ProgressHUD.showSuccess("please verify your email ")
} else {
go to main app or (login)
}
}