Created
September 25, 2019 18:56
-
-
Save catalinaturlea/2d44dbc22af21cb6022c7e67639edaa3 to your computer and use it in GitHub Desktop.
ViewController-version1
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
class ViewController: UIViewController { | |
// .... | |
@IBAction func loginButtonPressed() { | |
login(emailTextField.text ?? "", passwordTextField.text ?? "", completion: { success in | |
if !success { | |
showLoginError() | |
return | |
} | |
goToApp() | |
}) | |
} | |
func login(email: String, password: String, completion: ((Bool) -> Void)) { | |
if email.isEmpty { | |
completion(false) | |
} else if !isValidEmail(email) { | |
completion(false) | |
} | |
if password.isEmpty { | |
completion(false) | |
} | |
UserService.shared.login(email, password, completion: { (success, error) in | |
if success { | |
completion(true) | |
} | |
completion(false) | |
}) | |
} | |
// .... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment