Last active
January 22, 2017 20:56
-
-
Save ramamilaneh/ac86fcd5b4ab35b49effd4ac83d8321c to your computer and use it in GitHub Desktop.
This file contains 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
func forgotPasswordTapped(with sender: LoginView) { | |
let alertController = UIAlertController(title: "Forgot My Password", message: "To reset your password, please enter your email address.", preferredStyle: .alert) let sendAction = UIAlertAction(title: "Send", style: .default) { (action) in | |
let emailField = alertController.textFields![0] | |
if let email = emailField.text { | |
FIRAuth.auth()?.sendPasswordReset(withEmail: email, completion: { (error) in | |
if let error = error { | |
let alertController = UIAlertController(title: "Error", message: "\(error.localizedDescription)", preferredStyle: .alert) | |
let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil) | |
alertController.addAction(okAction) | |
self.present(alertController, animated: true, completion: nil) | |
} else { | |
UserNotification.show("Password reset e-mail sent") | |
} | |
}) | |
} | |
} | |
let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: nil) | |
alertController.addAction(sendAction) | |
alertController.addAction(cancelAction) | |
alertController.addTextField { (textfield) in | |
textfield.placeholder = "Enter E-mail address" | |
} | |
self.present(alertController, animated: true, completion: nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment