Guest User

Untitled

a guest
Nov 8th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. // A list of errors thrown by Firebase that can return a message the user can understand
  2. // or easily insert print statement so you can see the errors in your console.
  3.  
  4. public static func handleFirebaseError(errorCode: AuthErrorCode) -> String{
  5. switch errorCode {
  6. case .accountExistsWithDifferentCredential:
  7. return "Wrong Account Credentials"
  8. case .invalidCustomToken:
  9. return "Invalid Custom Token"
  10. case .customTokenMismatch:
  11. return "Custom Token Mismatch"
  12. case .invalidCredential:
  13. return "Invalid Credentials"
  14. case .userDisabled:
  15. return "Account disabled"
  16. case .operationNotAllowed:
  17. return "Operation Not Allowed"
  18. case .emailAlreadyInUse:
  19. return "Email Already In Use"
  20. case .invalidEmail:
  21. return "Invalid Email"
  22. case .wrongPassword:
  23. return "Invalid Password"
  24. case .tooManyRequests:
  25. return "Too Many Request"
  26. case .userNotFound:
  27. return "User Not Found"
  28. case .requiresRecentLogin:
  29. return "Requires Recent Log In"
  30. case .providerAlreadyLinked:
  31. return "Provider Already Linked"
  32. case .noSuchProvider:
  33. return "No Such Provider"
  34. case .invalidUserToken:
  35. return "Inavlid User Token"
  36. case .networkError:
  37. return "Check Your Network Connection"
  38. case .userTokenExpired:
  39. return "User Token Expired"
  40. case .invalidAPIKey:
  41. return "Invalid API Key"
  42. case .userMismatch:
  43. return "User Mismatch"
  44. case .credentialAlreadyInUse:
  45. return "Credentials Already In Use"
  46. case .weakPassword:
  47. return "Weak Password"
  48. case .appNotAuthorized:
  49. return "App Not Authorized"
  50. case .expiredActionCode:
  51. return "Expired Action Code"
  52. case .invalidActionCode:
  53. return "Invalid Action Code"
  54. case .invalidMessagePayload:
  55. return "Invalid Message Payload"
  56. case .invalidSender:
  57. return "Invalid Sender"
  58. case .invalidRecipientEmail:
  59. return "Invalid Recepient Email"
  60. case .missingEmail:
  61. return "Missing Email"
  62. case .missingIosBundleID:
  63. return "Missing Bundle Id"
  64. case .missingPhoneNumber:
  65. return "Missing Phone Number"
  66. case .invalidPhoneNumber:
  67. return "Invalid Phone Number"
  68. case .missingVerificationCode:
  69. return "Missing Verification Code"
  70. case .invalidVerificationCode:
  71. return "Invalid Verification Code"
  72. case .missingVerificationID:
  73. return "Missing VerificationID"
  74. case .invalidVerificationID:
  75. return "Invalid VerificationID"
  76. case .missingAppCredential:
  77. return "Missing App Credential"
  78. case .invalidAppCredential:
  79. return "Invalid App Credential"
  80. case .sessionExpired:
  81. return "Session Expired"
  82. case .quotaExceeded:
  83. return "Quota Exceeded"
  84. case .missingAppToken:
  85. return "Missing App Token"
  86. case .notificationNotForwarded:
  87. return "Notification Not Forwarded"
  88. case .appNotVerified:
  89. return "App Not Verified"
  90. case .captchaCheckFailed:
  91. return "Captcha Check Failed"
  92. case .invalidClientID:
  93. return "Invalid Client ID"
  94. case .nullUser:
  95. return "No User Found"
  96. case .keychainError:
  97. return "Keychain Error"
  98. case .internalError:
  99. return "Internal Error"
  100. default:
  101. return "General Error"
  102. }
  103. }
  104.  
  105. //Example
  106. /*
  107. @IBAction func signInTapped(_ sender: Any) {
  108. guard let email = emailTextField.text,
  109. let password = passwordTextField.text
  110. else{return}
  111.  
  112. FirebaseUtilities.signIn(email: email, password: password) { (succeed, errorCode) in
  113. if let error = errorCode {
  114. FirebaseUtilities.handleFirebaseError(errorCode: error)
  115. }
  116. }
  117. }
  118. */
Add Comment
Please, Sign In to add comment