MakeSchool-Tutorials / Makestagram-Swift-V3

14 stars 7 forks source link

8. Managing User Accounts - userRef #107

Open cobrien666 opened 6 years ago

cobrien666 commented 6 years ago

In the LoginViewController FUIAuthDelegate extension, my code is not stepping into the section that determines if a user already exists or is new, this block:

` let userRef = Database.database().reference().child("users").child(user.uid)

    userRef.observeSingleEvent(of: .value, with: { (snapshot) in
        if let userDict = snapshot.value as? [String : Any] {
            print("User already exists \(userDict.debugDescription).")
        } else {
            print("New user!")
        }
    })

`

I'm getting a valid userRef object and I have verified that users are being added by checking the Firebase Application console. However, when execution gets to the userRef.observeSingleEvent line, it steps over the entire If.. statement. I actually got to section 9 before and then realized that the segue to the Create Username view wasn't happening.

Is there something that I'm overlooking?