如何阻止新用户登录,直到他们在firebase swift中验证他们的电子邮件?

时间:2018-05-16 20:08:46

标签: swift firebase firebase-authentication

当用户通过电子邮件注册时,他们会获得他们提供给用户验证的电子邮件的验证链接。我希望未验证其电子邮件的用户无法登录或进入主屏幕,直到他们验证他们的电子邮件。这是我的代码。

      @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) 

      }

   }

0 个答案:

没有答案