简体   繁体   中英

My swift code performs a segue when even if it shows that an error is occuring in the firebase login

This is my code, the first part (Auth.auth.signin) is authenticating with Firebase if the emailId and password is correct. After that, if incorrect, it print incorrect. This part does show up in the console. However, the code performs the segue even though it is not supposed to. Why is this?

@IBAction func loginPressed(_ sender: Any) {
    //TODO: Log in the user
    Auth.auth().signIn(withEmail: emailTextfield.text!, password: passwordTextfield.text!) { (user, error) in
        print(error!)

        if(error != nil || user == nil){
            print("incorrect signin")
        }
        else{
            self.performSegue(withIdentifier: "goToChat", sender: self)
            print("Login was good")

        }
    }
}

Looks like you have assigned Segue from button. Remove the older one and create new Segue like shown below:

在此处输入图片说明

And add identifier for Segue .

You have done segue from your button. Remove it and add Segue from View Controller to view controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM