My intended flow is that someone reaches the signup page, enters their email and password, then when it is successfully processed then create a user in Firestone. After a lot of print lines, I can see the authentication part works just fine, but when I try to create the user in firestore it crashes. I suspect it's an async issue because I try to write the below code, but currUser?.uid is nil. Please help!
db.collection("users").document(currUser?.uid ?? "").setData(user) { err in
This is also how I'm trying to combat the async issue. The below is the code for the sign up button
Button(action: {
self.signUp()
self.viewModel.createUser()
})
I've also attached the error I am getting below:
2020-06-21 23:28:20.163164-0400 Routines[5662:144417] *** Assertion failure in firebase::firestore::api::DocumentReference::DocumentReference(model::ResourcePath, std::shared_ptr)(), /Users/paulachan/Documents/Apps/Routines/Pods/FirebaseFirestore/Firestore/core/src/api/document_reference.cc:67 2020-06-21 23:28:20.241127-0400 Routines[5662:144417] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Invalid document reference. Document references must have an even number of segments, but users has 1'