Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. if let errCode = FIRAuthErrorCode(rawValue: err!._code) {
  2.  
  3. switch errCode {
  4. case .errorCodeInvalidEmail:
  5. print("invalid email")
  6. case .errorCodeEmailAlreadyInUse:
  7. print("in use")
  8. default:
  9. print("Other error!")
  10. }
  11.  
  12. }
  13.  
  14. Auth.auth().createUser(withEmail: email, password: password) { (user: User?, error) in
  15.  
  16. if error != nil {
  17.  
  18.  
  19. if let errCode = AuthErrorCode(rawValue: error!._code) {
  20.  
  21. switch errCode {
  22. case .invalidEmail:
  23.  
  24. print("invalid email")
  25. // Create an alert message
  26. let alertMessage = UIAlertController(title: "Invalid Email", message: "Please check the entered email address", preferredStyle: .alert)
  27. // Attach an action on alert message
  28. alertMessage.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
  29. alertMessage.dismiss(animated: true, completion: nil)
  30. }))
  31. // Display the alert message
  32. self.present(alertMessage, animated: true, completion: nil)
  33.  
  34. case .emailAlreadyInUse:
  35.  
  36. print("in use")
  37. // Create an alert message
  38. let alertMessage = UIAlertController(title: "Existed Email", message: "The email existed in our database, login instead of registering", preferredStyle: .alert)
  39. // Attach an action on alert message
  40. alertMessage.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
  41. alertMessage.dismiss(animated: true, completion: nil)
  42. }))
  43. // Display the alert message
  44. self.present(alertMessage, animated: true, completion: nil)
  45.  
  46. case .weakPassword:
  47.  
  48. print("password is weak")
  49. // Create an alert message
  50. let alertMessage = UIAlertController(title: "Password is weak", message: "Use upper and lower characters along with numbers", preferredStyle: .alert)
  51. // Attach an action on alert message
  52. alertMessage.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in
  53. alertMessage.dismiss(animated: true, completion: nil)
  54. }))
  55. // Display the alert message
  56. self.present(alertMessage, animated: true, completion: nil)
  57.  
  58. default:
  59. print("Other error!")
  60. }
  61.  
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement