Guest User

Untitled

a guest
Jan 27th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. @IBAction func signInButton(_ sender: Any) {
  2.  
  3. self.view.endEditing(true)
  4. let email = emailText.text!.lowercased()
  5. let finalEmail = email.trimmingCharacters(in: .whitespacesAndNewlines)
  6. let password = passwordText.text!
  7.  
  8. if finalEmail.isEmpty || password.isEmpty {
  9.  
  10. let alertController = UIAlertController(title: "Error!", message: "Please fill in all the fields.", preferredStyle: .alert)
  11. alertController.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil))
  12. present(alertController, animated: true, completion: nil)
  13.  
  14. }else {
  15. SVProgressHUD.show()
  16.  
  17. Auth.auth().signIn(withEmail: email, password: password) { (user, error) in
  18.  
  19. if error == nil {
  20. if let user = user {
  21. print("(user.displayName!) has been signed in")
  22.  
  23. SVProgressHUD.dismiss()
  24.  
  25. // self.enter()
  26. self.performSegue(withIdentifier: "signInHome", sender: nil)
  27.  
  28. }else{
  29. SVProgressHUD.dismiss()
  30. print("error")
  31. let alertController = UIAlertController(title: "Low Blow!", message: "incorrect credentials", preferredStyle: .alert)
  32. alertController.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil))
  33. self.present(alertController, animated: true, completion: nil)
  34.  
  35.  
  36. print(error?.localizedDescription as Any)
  37. }
  38. }
  39. }
  40. }
  41.  
  42. }
Add Comment
Please, Sign In to add comment