I am setting up a login page with Firebase and I've run into an error where uid
isn't getting recognized. Here's my code:
FIRAuth.auth()?.createUser(withEmail: email, password: password, completion: { (FIRUser,error) in
if error != nil {
print(error)
return
}
guard let uid = user?.uid else {
return
}
I also can't command-click into FIRUser
, however if I get rid of the guard statement, authentication works perfectly fine.
I have Firebase and FirebaseDatabase imported (can't import FirebaseAuth, it's crossed out), so it's not that.
Any idea why I can't access FIRUser
and use uid
?
You need to create the variable
user
inside your closure. Rewrite your function to this instead.