Last active
April 4, 2021 07:32
-
-
Save KrauserHuang/9e66ca2a886115c12f0fa5d8d6b9fd9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func loginPressed(_ sender: UIButton) { | |
let error = validateTextField() | |
if error != nil { | |
popAlert(title: "Error occured", message: error!, alertTitle: "OK") { (action) in | |
self.emailTextField.text = "" | |
self.passwordTextField.text = "" | |
} | |
} else { | |
if let email = emailTextField.text, | |
let password = passwordTextField.text { | |
Auth.auth().signIn(withEmail: email, password: password) { authResult, error in | |
// remove [weak self] & guard let strongSelf = self else { return } | |
if let error = error { | |
self.popAlert(title: "Error occured", message: error.localizedDescription, alertTitle: "OK") { (action) in | |
self.emailTextField.text = "" | |
self.passwordTextField.text = "" | |
} | |
print(error.localizedDescription) | |
} else { | |
if let user = Auth.auth().currentUser { | |
self.uid = user.uid | |
self.performSegue(withIdentifier: Constant.Segue.loginSegue, sender: self) | |
print("login success!") | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment