0

My code doesn't work properly. I created google firebase Authentication. My code is down

    @IBAction func loginClicked(_ sender: UlButton) {
      if let email = usernameText.text, let password = passwordText.text { 
         Auth.auth().signIn(withEmail: email, password: password) {authResult, error in 
            self.makeAlert(titleInput: "Error", messagelnput:"Error")
    }
    self.performSegue(withldentifier: "goToViewController", sender: nil) 
    }
}

Then I wrote this code. Error message is displayed when you enter wrong email and wrong password on login page. But it also goes to the other page(Home Page, ldentifier: "goToViewController"). I dont want do this. When I enter the wrong email and wrong password, I want to show error message only.

How can I do that? Thank you for your help

1 Answer 1

1

You need to add performSegue inside the closure response of firebase

 @IBAction func loginClicked(_ sender: UlButton) {
      if let email = usernameText.text, let password = passwordText.text { 
         Auth.auth().signIn(withEmail: email, password: password) {authResult, error in 
           if error == nil { 
              self.performSegue(withldentifier: "goToViewController", sender: nil) 
           }
           else { 
              self.makeAlert(titleInput: "Error", messagelnput:"Error") 
            } 
        }
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.