No Description

SignUpViewController.swift 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // SignUpViewController.swift
  3. // EncuestaMarle
  4. //
  5. // Created by Tatiana Castro on 5/20/19.
  6. // Copyright © 2019 Marle. All rights reserved.
  7. //
  8. import UIKit
  9. import FirebaseAuth
  10. class SignUpViewController: UIViewController {
  11. @IBOutlet weak var email: UITextField!
  12. @IBOutlet weak var password: UITextField!
  13. @IBOutlet weak var passwordConfirm: UITextField!
  14. @IBOutlet weak var consentimiento: UIButton!
  15. @IBAction func signUpAction(_ sender: Any) {
  16. if password.text != passwordConfirm.text {
  17. let alertController = UIAlertController(title: "Password Incorrect", message: "Please re-type password", preferredStyle: .alert)
  18. let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
  19. alertController.addAction(defaultAction)
  20. self.present(alertController, animated: true, completion: nil)
  21. }
  22. else{
  23. Auth.auth().createUser(withEmail: email.text!, password: password.text!){ (user, error) in
  24. if error == nil {
  25. self.performSegue(withIdentifier: "signupToHome", sender: self)
  26. }
  27. else{
  28. let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
  29. let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
  30. alertController.addAction(defaultAction)
  31. self.present(alertController, animated: true, completion: nil)
  32. }
  33. }
  34. }
  35. }
  36. override func viewDidLoad() {
  37. super.viewDidLoad()
  38. }
  39. /*
  40. // MARK: - Navigation
  41. // In a storyboard-based application, you will often want to do a little preparation before navigation
  42. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  43. // Get the new view controller using segue.destination.
  44. // Pass the selected object to the new view controller.
  45. }
  46. */
  47. }