Hello, I am receiving an error when following the “Firebase Authentication tutorial 2020” on youtube. I reached the completion of the sign up view controller around the 1:14:00 mark where I encountered an error when attempting to sign up that says “Error Creating User” which I personally made my error string however I cannot understand why it keeps saying this, and I saw a couple others having the same issue but couldn’t find another forum post about it. Here is a snippet of my code. If you can help me out, it would be very much appreciated… cheers!
…
@IBAction func signUpTapped(_ sender: Any) {
//Validate Fields
let error = validateFields()
if error != nil {
showError(message: error!)
}
else {
let firstName = firstNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let lastName = lastNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let email = emailTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let password = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
//Create User
Auth.auth().createUser(withEmail: email, password: password) { (result, err) in
if err != nil {
self.showError(message: "Error creating user.")
}
else {
//user created and store data
let db = Firestore.firestore()
db.collection("users").addDocument(data: [
"firstname": firstName,
"lastname": lastName,
]) { err in
if err != nil {
self.showError(message: "User data couldn't be saved.")
}
}
transitionToHome()
}
}
//transition to home screen
func transitionToHome() {
let homeViewController = storyboard?.instantiateViewController(withIdentifier: Constants.Storyboard.homeViewController) as? HomeViewController
view.window?.rootViewController = homeViewController
view.window?.makeKeyAndVisible()
}
}
}
…