Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Add signup custom confirmation redirect url #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions endpoints/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ func (c *Client) Signup(req types.SignupRequest) (*types.SignupResponse, error)
return nil, err
}

if req.ConfirmationRedirectUrl != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect to see updates to the integration tests to exercise this new branch and verify the response includes the expected redirect before this can be merged

q := r.URL.Query()
q.Add("redirect_to", req.ConfirmationRedirectUrl)
r.URL.RawQuery = q.Encode()

// Set up a client that will not follow the redirect.
c.client = noRedirClient(c.client)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that the JS client appears to be forwarding a redirect_to parameter like this, but In my testing, I was unable to get the server to actually return a redirect here. Were you able to successfully make use of this redirect param?

}

resp, err := c.client.Do(r)
if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions types/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,11 @@ type SettingsResponse struct {
}

type SignupRequest struct {
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
Password string `json:"password,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`

Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
Password string `json:"password,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
ConfirmationRedirectUrl string `json:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think RedirectToURL would be a preferable name here - more directly describes what the URL is for, and uses Go's preferred casing (i.e. UrlURL)

// Provide Captcha token if enabled.
SecurityEmbed
}
Expand Down