Currently I am trying to fetch user data, but there is one huge problem. The uid of currently logged in user is different then UID of the same user in my database. Here are two images where you can see it. Below the images is my code from my SignUpController in Swift. I need it to be the same for the database and auth. Thanks for help.
And here is second one
func emailSingUp(){
guard let email = emailTextField.text, let password = passwordTextField.text,let name = nameTextField.text else {
print("unsuccessful signup")
return
}
Auth.auth().createUser(withEmail: email, password: password) { (user, error) in
if error != nil{
print(error!)
return
}
}
guard let uid = Auth.auth().currentUser?.uid else{
print("There is no UID to access")
return
}
let ref = Database.database().reference(fromURL: "https://yourapp.firebaseio.com/")
let userReference = ref.child("users").child(uid)
let values = ["name":name, "email":email]
userReference.updateChildValues(values) { (err, ref) in
if err != nil{
print(err!)
return
}
}
I moved some code into the right spot. Also, you update a value called "uid" but you nowhere have a reference to that. I hope the code below works.
If this works, you variable called uid is from an old account.