I'm having an issue with Firebase and it's email verification flow. I'm able to create a new user, email with a link to verify email address is delivered with no issues. Now, just for testing purposes I'm not clicking on the link to verify the email, but, if I open the app, I'm able to access and do anything. I'm not sure what I'm missing or what I'm doing wrong. I've been stuck with this for the past couple days. Any help is greatly appreciated.
my code
@IBAction func loginBtnTapped(_ sender: Any) {
SVProgressHUD.show()
guard let email = emailTxt.text,
let password = passwordTxt.text else { return }
Auth.auth().signIn(withEmail: email, password: password) {
(user, error) in
if error != nil {
let alert = UIAlertController(title: "Login Error",
message:"Incorrect Email and/or Password", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style:
.default) { _ in })
self.present(alert, animated: true){}
if let error = error {
print("error: \(error.localizedDescription)")
}
if Auth.auth().currentUser?.isEmailVerified == false {
let alert = UIAlertController(title: "Unable to
login", message:"Pending: email verification", preferredStyle:
.alert)
alert.addAction(UIAlertAction(title: "OK", style:
.default) { _ in })
self.present(alert, animated: true){}
print("")
SVProgressHUD.dismiss()
}
}
self.dismiss(animated: true, completion: nil)
SVProgressHUD.dismiss()
}
}
Expected results
Newly created user should not be able to login and open the app unless email is verified.