nedpals / supabase-go

Unofficial Supabase client library for Go.
https://pkg.go.dev/github.com/nedpals/supabase-go
MIT License
362 stars 69 forks source link

How to update user password if the user is not loged in ? #53

Open geoport opened 2 months ago

geoport commented 2 months ago

I want to add a forgot password functionality to my web app. I can send a password recovery link to user but in order to update user I need user token.

emilkm commented 2 months ago

With GO + TEMPL + HTMX something like this worked for me

image

With another combo, you could have a front end router, and have a redirect or two less.

I have above working, but with couple of tiny changes to supabase-go library, to support redirect_to parameter, and return the underlying errors.

geoport commented 2 months ago

Thanks for the reply, my problem was with Auth.UpdatePassword function. I wrote a js script to fetch access token from the url and write it into a hidden input field. Then I could fetch the token after post request but when I try to change the password UpdatePassword throw error as empty string so that I couldn't figure out what the problem was. I solved the problem by sending request to supabase directly. I think UpdatePassword function should return readable errors.

emilkm commented 2 months ago

Glad to hear you solved it.