GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
530 stars 76 forks source link

Getting "Null" When calling get_user_data() #329

Closed Rikoo132 closed 1 year ago

Rikoo132 commented 1 year ago

Describe the bug When I call get_user_data() and print it, it prints null even the user is logged in.

Code I used : func _on_FirebaseAuth_login_succeeded(auth): var user = Firebase.Auth.get_user_data() print(user)

WolfgangSenff commented 1 year ago

Yes, that's expected. You're getting null because it's a void return. https://github.com/GodotNuts/GodotFirebase/blob/c2b6a0952fe57c1e1de23e47dcb59344b64a1c23/addons/godot-firebase/auth/auth.gd#L530

What you need to do is connect to the userdata_received signal, found here: https://github.com/GodotNuts/GodotFirebase/blob/c2b6a0952fe57c1e1de23e47dcb59344b64a1c23/addons/godot-firebase/auth/auth.gd#L22

In addition to this, when you receive the auth variable in your handler the way you have it, that is already the user data, so you can just look at it there.