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

Sign out issue with anonymous user #44

Closed SeaKrill closed 2 years ago

SeaKrill commented 2 years ago

If you sign in a user as anonymous it prevents you from creating an account even after calling a signout function, any way to prevent this?

SeaKrill commented 2 years ago

I fixed the issue but I don't really know if its the best solution, if it seems fine then I'll close the ticket but was wondering if i could get a second opinion.

I changed the rpc function to work like this:

func rpc(function_name : String, arguments : Dictionary = {}, supabase_query : SupabaseQuery = null, anon : bool = false) -> DatabaseTask:
    if anon == false:
        _bearer = get_parent().auth._bearer
    if anon == true:
        var string = ["Authorization: Bearer " + str(get_parent().config.supabaseKey)]
        _bearer = string

where putting a bool arg defines whether or not youre making an anon call. For whatever reason this prevents the issue where as if you instead log them in as an anon user it wont let you create an account until they relaunch the program.