我的代码无法正常工作。我创建了Google 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
self.makeAlert(titleInput: "Error", messagelnput:"Error")
}
self.performSegue(withldentifier: "goToViewController", sender: nil)
}
}
然后我编写了这段代码。当您在登录页面上输入错误的电子邮件和错误的密码时,将显示错误消息。但它也转到另一页(主页,标识符:“ goToViewController”)。我不想这样做。输入错误的电子邮件和错误的密码时,我只想显示错误消息。
我该怎么做? 谢谢您的帮助
答案 0 :(得分:1)
您需要在Firebase的关闭响应中添加performSegue
@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")
}
}
}
}