Skip to content

Instantly share code, notes, and snippets.

@ramamilaneh
Last active January 22, 2017 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramamilaneh/ac86fcd5b4ab35b49effd4ac83d8321c to your computer and use it in GitHub Desktop.
Save ramamilaneh/ac86fcd5b4ab35b49effd4ac83d8321c to your computer and use it in GitHub Desktop.
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