gotrue-go icon indicating copy to clipboard operation
gotrue-go copied to clipboard

VerifyForUser function returns success JSON response in error

Open thisisthemurph opened this issue 5 months ago • 0 comments

Bug report

Describe the bug

I'm using the VerifyForUser function (here) to verify an OTP during my password reset process.

I note that I am getting a response of nill, error and the error is essentially a JSON string of the 200 success result. On line 142 it is checking to ensure the response from the server is http.StatusSeeOther and if it is not, it places the response in the body of the error, even though it is a 200 OK in this case.

To Reproduce

Here is a snippet of the code I used that results in this behaviour:

_, err := h.Supabase.Auth.VerifyForUser(types.VerifyForUserRequest{
	Type:       "recovery",
	Token:      req.OTP,
	Email:      req.Email,
	RedirectTo: h.Config.ClientBaseURL + "/auth/password-reset",
})

// Here I have my own function for parsing the success session response from the error 
session, jsonParseErr := sbext.ParseSessionFromErrJson(err)

Expected behavior

I would have expected a 200 response to be returned as the first param, not in the error.

System information

Snippets from my go.mod file:

require(
	github.com/supabase-community/gotrue-go v1.2.0
	github.com/supabase-community/supabase-go v0.0.4
        github.com/supabase-community/functions-go v0.1.0 // indirect
	github.com/supabase-community/postgrest-go v0.0.11 // indirect
	github.com/supabase-community/storage-go v0.7.0 // indirect
)

Additional context

This could be because I have the incorrect process or that I am using the incorrect function. I noted that there is a Verify function above that uses GET rather than POST. I may look at that at some point, but my current method is actually working right now.

thisisthemurph avatar Sep 22 '24 14:09 thisisthemurph