supabase-community / godot-engine.supabase

A lightweight addon which integrates Supabase APIs for Godot Engine out of the box.
MIT License
159 stars 17 forks source link

Signed_out signal emits before resetting variables. #54

Closed sindrsh closed 1 year ago

sindrsh commented 1 year ago

https://github.com/supabase-community/godot-engine.supabase/blob/425800d67c57caad51ee677b70b023e3108c9592/addons/supabase/Auth/auth.gd#L313

The result is that when a new sign in is attempted when signed_out signal is emitted, the Supabase.sign_in method fails to sign in a new user without reporting an error.

assert(Supabase.auth.connect("signed_in", self, "_on_signed_in") == 0)
assert(Supabase.auth.connect("signed_out", self, "_on_signed_out") == 0)

_sign_in("example@mail.com", "example_pswd")

func _sign_in(user, password):
    Supabase.auth.sign_in(user, password)   

func _on_signed_in(client):
    Supabase.auth.sign_out()

func _on_signed_out():
    _sign_in("example@mail.com", "example_pswd)

My first thought on this is simply moving the emit(signed_out) to line 317, but it could be I'm missing on something from the bigger picture here.

fenix-hub commented 1 year ago

Hi @sindrsh , what do you mean by "fails to sign in a new user"? Is the signal _on_signed_in never called? Or is the client variable null? Have you tried connecting the on_error signal to check if there is any error (or yielding on the AuthTask to get both data and error)? https://github.com/supabase-community/godot-engine.supabase/blob/425800d67c57caad51ee677b70b023e3108c9592/addons/supabase/Auth/auth_task.gd#L30-L32 Thanks

sindrsh commented 1 year ago

When performing a new sign when the signed_out signal is emitted, SubabaseAuth.sign_in() returns _Checkout() because _auth != "" (line 94 of SupabaseAuth). From there the process continues without catching any errors but it does not result in a new sign in.

sindrsh commented 1 year ago

Thank you so much for this tool by the way :+1:

fenix-hub commented 1 year ago

You are welcome, I'll look into it later today :)